$php_mysql$ Posted August 21, 2011 Share Posted August 21, 2011 got this function in php.net i guess function mywordwrap($string) { $length = strlen($string); for ($i=0; $i<=$length; $i=$i+1) { $char = substr($string, $i, 1); if ($char == "<") $skip=1; elseif ($char == ">") $skip=0; elseif ($char == " ") $wrap=0; if ($skip==0) $wrap=$wrap+1; $returnvar = $returnvar . $char; if ($wrap> // alter this number to set the maximum word length { $returnvar = $returnvar . "<wbr>"; $wrap=0; } } return $returnvar; } after using this when i try to validate my page in http://validator.w3.org i get this error Line 124, Column 38: end tag for "wbr" omitted, but OMITTAG NO was specified <td width="15%">sdfasdfsdfadfddfdfsafasd<wbr>a</td> ✉ You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". what is the fix for this? Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/ Share on other sites More sharing options...
darkfreaks Posted August 21, 2011 Share Posted August 21, 2011 you can try <span style="word-spacing:0.25">text</span> Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260118 Share on other sites More sharing options...
$php_mysql$ Posted August 21, 2011 Author Share Posted August 21, 2011 instead of using this function? Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260142 Share on other sites More sharing options...
darkfreaks Posted August 21, 2011 Share Posted August 21, 2011 why not use nl2br it will output line breaks Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260153 Share on other sites More sharing options...
$php_mysql$ Posted August 21, 2011 Author Share Posted August 21, 2011 nl2br will not work for it would make my table go out of the main content. the function above works like i need but bcoz or the <wbr> i get validation error i got a row for title 70 characters max and the with is 50% without wraping the text my table gets messed up :-D Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260230 Share on other sites More sharing options...
darkfreaks Posted August 21, 2011 Share Posted August 21, 2011 $returnvar = $returnvar . "/r";//insert carriage return $returnvar = $returnvar . "/n"; //new line break Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260242 Share on other sites More sharing options...
$php_mysql$ Posted August 21, 2011 Author Share Posted August 21, 2011 thanks bro found a substitute :-) function mywordwrap1($text,$nr=35) { $mytext=explode(" ",trim($text)); $newtext=array(); foreach($mytext as $k=>$txt) { if (strlen($txt)>$nr) { $txt=wordwrap($txt, $nr, "-", 1); } $newtext[]=$txt; } return implode(" ",$newtext); } tho it puts a - it would have been nice if it didn but it does the work :-) thanks soo much. Quote Link to comment https://forums.phpfreaks.com/topic/245345-word-wrap-is-giving-error-while-validating-page/#findComment-1260247 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.