Code: Select all
<?php
/**
* Example usage:
*
* // Your text
* $text = "This is a sentence which contains some words.";
*
* // Or from a database result
* $text = $row['text'];
*
* // Then put it into the function
* $text = word_wrap($text);
*
* // Output the result
* echo $text;
*/
function word_wrap($text) {
// Define the characters to display per row
$chars = "10";
$text = wordwrap($text, $chars, "<br />", 1);
return $text;
}
?>