I had some issues trying to get both word wrapping and new
line detection but with some of the help from the comments
below i got this. (thanks to jwe for the main part of the
code here)
<?php
function ttfWordWrappedText($text, $strlen = 38) {
$text = urldecode($text);
$text = explode("n", $text);
$i = 0;
foreach($text as $text)
{
while(strlen($text) > $strlen) {
$startPoint = $strlen - 1;
while(substr($text, $startPoint, 1) != " ")
{
$startPoint--;
}
$line[$i][] = trim(substr($text, 0, $startPoint));
$text = substr($text, $startPoint);
}
$line[$i][] = trim($text);
$i++;
}
return $line;
}
?>
This returns an array for each newline entered and subarray
for each wordwrapped line to print.
ie.
Array
(
[0] => Array
(
[0] => This is the first long line
[1] => that i entered.
)
[1] => Array
(
[0] => And this is the new line after that.
)
)
----
Server IP: 213.181.110.1
Probable Submitter: 157.157.96.98
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- https://master
.php.net/note/edit/79024
Del: integrated -- h
ttps://master.php.net/note/delete/79024/integrated
Del: useless -- http
s://master.php.net/note/delete/79024/useless
Del: bad code -- htt
ps://master.php.net/note/delete/79024/bad+code
Del: spam -- https:/
/master.php.net/note/delete/79024/spam
Del: non-english --
https://master.php.net/note/delete/79024/non-english
Del: in docs -- http
s://master.php.net/note/delete/79024/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/79024
Reject -- https://mast
er.php.net/note/reject/79024
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|