note 18414 deleted from function.wordwrap by zak

From: Date: Tue, 22 Jan 2002 14:16:22 +0000
Subject: note 18414 deleted from function.wordwrap by zak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25691@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; }

« previous php.notes (#25691) next »