note 18415 added to function.wordwrap
| From: | sheepsATmindless dot com at php2 dot chek dot com | Date: | Tue, 22 Jan 2002 04:50:28 +0000 |
| Subject: | note 18415 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25674@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;
}
--
http://www.php.net/manual/en/function.wordwrap.php
http://master.php.net/manage/user-notes.php?action=edit+18415
http://master.php.net/manage/user-notes.php?action=delete+18415
http://master.php.net/manage/user-notes.php?action=reject+18415