note 18414 added to function.wordwrap

From: Date: Tue, 22 Jan 2002 04:41:05 +0000
Subject: note 18414 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-25673@lists.php.net to get a copy of this message
-- could someone please make this edit control a bit larger? -- If you have a problem with this worwrap which you aren't able to give arguments for NOT parsing through some string parts (like html codes, which could be longer then ie.80 chars), here's how to do it. This one, cuts words in $str longer then $cols long, and puts and $cut in it. It escapes everything whitin "<>". So "<longggggggggggggtext>" will not be cutted, and just "longggggggggggggtext", will be cutted! :) have fun with it. function sheep_html_wordwrap($str,$cols,$cut){ $count=0; $tagcount=0; for ($i=1; $i<=strlen($str);$i++){ if ($str[$i]=='<') $tagcount++; elseif ($str[$i]=='>'){ if ($tagcount>0) $tagcount--; } else{ if (($tagcount==0)){ if ($str[$i]==' ') $count=0; else{ $count++; if ($count>$cols){ $str=substr($str,0,$i-1).$replacestr.substr($str,$i+1); $count=0; } } } } } return $str; } -- http://www.php.net/manual/en/function.wordwrap.php http://master.php.net/manage/user-notes.php?action=edit+18414 http://master.php.net/manage/user-notes.php?action=delete+18414 http://master.php.net/manage/user-notes.php?action=reject+18414

« previous php.notes (#25673) next »