Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- adding space between words preg_replace
October 29, 2007, 8:42 pm
rate this thread
the database. However the results seem to bunch up. Here's what I'm
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
What do I need to add to the expression to get the desired space
Re: adding space between words preg_replace
$new = preg_replace("/[^\w\s]/", "", $old);
Then again, why do a htmlspecialchars() if you're going to maim them
anyway? There's '&',';',0-9, etc... 'André Tös' might object to being
called 'Andreacute Toumls'. Also, try to store information as it is in a
database, not the presentation. While it might seem a good idea to use
htmlspecialchars() once here, it will be a pain when you're going to
search the database, or output data in other formats like a downloadable
report (pdf, txt, whatever).
What is it exactly that you don't want there, and why?