RE: [PHP] wordwrap not working

2002-02-20 Thread Martin Towell

Are you looking at the output in a web browser?

Martin

-Original Message-
From: Michael P. Carel [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 21, 2002 2:25 PM
To: php
Subject: [PHP] wordwrap not working



Hi,

Im testing the example in the
http://www.php.net/manual/en/function.wordwrap.php and it seems not working
it still printing the whole word and not wrapping. Im using php4.05 in my
redhat 6.2 using an apache.
Here's the sample:
?
$text = The quick brown fox jumped over the lazy dog.;
$newtext = wordwrap( $text, 20 );

echo $newtext\n;
?

it should print like this:

The quick brown fox
jumped over the lazy dog.

but it still printing like this:

The quick brown fox jumped over the lazy dog.



Please help



Regards,
Mike



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] wordwrap not working

2002-02-20 Thread David Redmond

If your viewing the output through a browser, try this;

?
$text = The quick brown fox jumped over the lazy dog.;
$newtext = wordwrap( $text, 20, br);
echo $newtext\n;
?

-Original Message-
From: Michael P. Carel [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, 21 February 2002 1:25 PM
To: php
Subject: [PHP] wordwrap not working



Hi,

Im testing the example in the
http://www.php.net/manual/en/function.wordwrap.php and it seems not working
it still printing the whole word and not wrapping. Im using php4.05 in my
redhat 6.2 using an apache.
Here's the sample:
?
$text = The quick brown fox jumped over the lazy dog.;
$newtext = wordwrap( $text, 20 );

echo $newtext\n;
?

it should print like this:

The quick brown fox
jumped over the lazy dog.

but it still printing like this:

The quick brown fox jumped over the lazy dog.



Please help



Regards,
Mike



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] wordwrap not working

2002-02-20 Thread Joel Boonstra

snip
 it should print like this:

 The quick brown fox
 jumped over the lazy dog.

 but it still printing like this:

 The quick brown fox jumped over the lazy dog.

HTML treats bunches of whitespace as one space.  Look at the source of the
page; you'll see that it's doing what it should.

If you want your HTML to appear wordwrapped, modify your PHP to use the
'nl2br()' function:

?
$text = The quick brown fox jumped over the lazy dog.;
$newtext = nl2br(wordwrap( $text, 20 ));

echo $newtext\n;
?

This will convert all newlines to br tags, and your HTML output will
look just like your text output.

Joel

-- 
[ joel boonstra | [EMAIL PROTECTED] ]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] wordwrap not working

2002-02-20 Thread Joel Boonstra

 If your viewing the output through a browser, try this;

 ?
 $text = The quick brown fox jumped over the lazy dog.;
 $newtext = wordwrap( $text, 20, br);
 echo $newtext\n;
 ?

Ah, this is a better solution than mine -- I didn't know wordwrap had the
3rd (and 4th) parameters till now.

Joel

-- 
[ joel boonstra | [EMAIL PROTECTED] ]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] wordwrap not working

2002-02-20 Thread Steven Walker

This may be a nl2br() problem. If you are setting \n as your newline 
character, it probably needs to be br if your just echoing it. 
Depending on where it ultimately gets displayed, you'll want one or the 
other. For example, sending an email message you want \n.

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

On Wednesday, February 20, 2002, at 07:25  PM, Michael P. Carel wrote:


 Hi,

 Im testing the example in the
 http://www.php.net/manual/en/function.wordwrap.php and it seems not 
 working
 it still printing the whole word and not wrapping. Im using php4.05 in 
 my
 redhat 6.2 using an apache.
 Here's the sample:
 ?
 $text = The quick brown fox jumped over the lazy dog.;
 $newtext = wordwrap( $text, 20 );

 echo $newtext\n;
 ?

 it should print like this:

 The quick brown fox
 jumped over the lazy dog.

 but it still printing like this:

 The quick brown fox jumped over the lazy dog.



 Please help



 Regards,
 Mike



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php