note 91526 added to function.wordwrap
| From: | MarcinDobruk | Date: | Mon, 15 Jun 2009 09:21:09 +0000 |
| Subject: | note 91526 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156870@lists.php.net to get a copy of this message | ||
Word wrap from left to right (standard) and from right to left.
function myWordWrap ($string, $length=3, $wrap=',', $from='left') {
if ($from=='left') $txt=wordwrap($string, $length, $wrap, true);
if ($from=='right') {
// string to array
$arr_l=array();
for ($a=0;strlen($string)>$a;$a++) $arr_l[$a]=$string{$a};
// reverse array
$arr_r=array_reverse($arr_l);
// array to string
$string_r='';
foreach ($arr_r as $arr_line => $arr) $string_r.=$arr;
// add wrap to reverse string
$string_r=wordwrap($string_r, $length, $wrap, true);
// reverse string to array
$arr_r=array();
for ($a=0;strlen($string_r)>$a;$a++) $arr_r[]=$string_r{$a};
// reverse array again
$arr_l=array_reverse($arr_r);
// string with wrap
$txt='';
foreach ($arr_l as $arr_line => $arr) $txt.=$arr;
}
return $txt;
}
----
Server IP: 92.48.74.199
Probable Submitter: 195.173.12.199
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/91526
Del: integrated -- https://master.php.net/note/delete/91526/integrated
Del: useless -- https://master.php.net/note/delete/91526/useless
Del: bad code -- https://master.php.net/note/delete/91526/bad+code
Del: spam -- https://master.php.net/note/delete/91526/spam
Del: non-english -- https://master.php.net/note/delete/91526/non-english
Del: in docs -- https://master.php.net/note/delete/91526/in+docs
Del: other reasons-- https://master.php.net/note/delete/91526
Reject -- https://master.php.net/note/reject/91526
Search -- https://master.php.net/manage/user-notes.php