Inserting spaces
Moderator: General Moderators
Inserting spaces
How do I keep extra spaces from being stripped when I send a paragraph to a MySQL db and then display it later?
Sorry what does that mean? I am not using the trim function or anything just:AFAIK
Code: Select all
$text = nl2br($_POSTї'text']);
echo $text;just as newlines aren't showed in html , spaces aren't either.
for newlines you can use nl2br... spaces you should display as
[php_man]htmlentities[/php_man] doesn't seem to replace spaces by so i suggest you
for newlines you can use nl2br... spaces you should display as
[php_man]htmlentities[/php_man] doesn't seem to replace spaces by so i suggest you
Code: Select all
$string = preg_replace("/\s/", " ", $string);- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
This doesn't seem to be working, here is the code I used:
Then later I used
Code: Select all
$text = nl2br($_POSTї'text']);
$revised_text = preg_replace("/\s/", " ", $text);Code: Select all
echo $revised_textmust something in your code because:
outputs:
Code: Select all
$string = "ik ben veel ' spaties ver";
$string = preg_replace("/\s/", " ", $string);
echo $string;Code: Select all
ik ben      veel ' spaties ver