Jump to content

word wrap is giving error while validating page


$php_mysql$

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.