note 9400 added to Chop
| From: | duka at piar dot hu | Date: | Wed, 01 Nov 2000 16:31:23 +0000 |
| Subject: | note 9400 added to Chop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7240@lists.php.net to get a copy of this message | ||
If you have many NEWLINES in a string, you can use explode->implode.
Example:
...
<form action...
<textarea name=text cols=70 rows=10></textarea>...</form>
echo $text; # makes "line1\nline2\nline3\n..."
$text=explode("\n",$text);
$text=implode(" ",$text); # or $text=implode("<br>",$text);
echo $text; # makes "line1 line2 ..." or "line1<br>line2<br>..."
It is important when you write it and after that read it in a file. Like:
$ow = fopen("file.txt", "w");
fputs($text, $ow);
fclose($ow);
$or = fopen("file.txt", "r");
$szov = fgets($or, 4096);
fclose($or);
echo $szov; # makes "line1" if you don't change "\n" to " " or
"<br>"
(Sorry for my bad english.)
http://www.php.net/manual/hu/function.chop.php