note 18415 deleted from function.wordwrap by zak
| From: | zak@php.net | Date: | Tue, 22 Jan 2002 14:16:51 +0000 |
| Subject: | note 18415 deleted from function.wordwrap by zak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25692@lists.php.net to get a copy of this message | ||
Sorry I made a mistake in the last AddNote message. This one is correct, I forgot to change a var.
_____
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).$cut.substr($str,$i+1);
$count=0;
}
}
}
}
}
return $str;
}