Re: Replacing a space with an underscore
| From: | James | Date: | Thu, 01 May 2003 15:04:38 +0000 |
| Subject: | Re: Replacing a space with an underscore | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145969@lists.php.net to get a copy of this message | ||
Mysql:
SELECT REPLACE(blah,' ','_') as blahWithUnderScore WHERE x=x
PHP:
$string = str_replace(" ","_", $string);
$string = preg_replace("/[\s]/","_",$string);
$string = eregi_replace("[[:space:]]","_",$string);
I would use the mySql way.
Ron Allen wrote:
What I would like to do... I would like to have either MySql or PHP replace a space with an underscore from a MySql query. Any ideas on how to do that? I have something like this select * from table1 where blah = blah echo "*$blah*"; I could use Excel to remove all the spaces, but that would not be a true script....kind of cheating.....any help would be appreciated!!!