note 9400 deleted from function.chop by irc-html
| From: | irc-html@php.net | Date: | Wed, 16 Jan 2002 16:20:27 +0000 |
| Subject: | note 9400 deleted from function.chop by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24898@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.)