note 79024 added to function.imagettftext
| From: | waage at osu1 dot php dot net | Date: | Wed, 07 Nov 2007 15:31:55 +0000 |
| Subject: | note 79024 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132080@lists.php.net to get a copy of this message | ||
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 -- https://master.php.net/note/delete/79024/integrated
Del: useless -- https://master.php.net/note/delete/79024/useless
Del: bad code -- https://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 -- https://master.php.net/note/delete/79024/in+docs
Del: other reasons-- https://master.php.net/note/delete/79024
Reject -- https://master.php.net/note/reject/79024
Search -- https://master.php.net/manage/user-notes.php