Jump to content

[SOLVED] word wrap still wont work =/


SirChick

Recommended Posts

I have a word wrap feature i just implement i literally copied and pasted yet it totally didnt work when i tested it lol...

 

I got this:

 

<td width="600" align=center><?$Message = wordwrap($Message, 600, "<br />\n"); ?><?=$Message?></td>

 

It says on this site:

http://us3.php.net/wordwrap

 

width

 

The column width. Defaults to 75.

 

 

And as you see i have matched the width as 600 equally to the td width but i tested it and it pushed it way of my screen it didn't wrap to a new line at all.

Even if i set the 600 to 60 it still wont wrap.

 

Link to comment
Share on other sites

Change

wordwrap($Message, 600,

to a much smaller number.. what the example was pretty much telling you is in your case you put 600, if a woooooooooooord is 600+ characters long it will break it down every 600 characters until the word is done until the next space.. try 12.. or 20.. and see how that works..

 

Link to comment
Share on other sites

Does this work for you?

<?php
$message = <<<EOL

This is a really really really long message that i want to wrap over
several lines or something

EOL;

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
    <head>
        <title>word wrap</title>
    </head>
    <body>
        <table>
            <tr>
                <td align="center" style="width:600px;border:1px solid red;"><?php echo wordwrap($message,10,"<br/>") ?></td>
            </tr>
       </table>
    </body>
</html>

Link to comment
Share on other sites

<td width="600" align=center><?$Message = wordwrap($Message, 50, "<br />\n"); ?><?=$Message?></td>

 

Still nothing observe print screen provided below!

 

 

Kris ..a word wrap is to wrap a long word not a long sentence..i thought anyway?

 

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

<?php
echo "<b>Message Orginal: (no tables)</b><br>";
$message = "what is gooooooooooooooooooooooooooing on dawg!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
echo $message . "<br><br>";
echo "<b>Message with Wrap (no tables):</b><br>";
$blah = wordwrap($message,10,"<br \>", true);
echo "$blah<br \>";
?>

 

Sample @ http://www.monkeytooth.net/tests/messg.php

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.