Jump to content

Replace space with underscore character in string


renno

Recommended Posts

I have a variable containing a string submitted from a form:

[code]$string = ($_POST["string"]);[/code]

I'm struggling to build some code that would replace any spaces in the string with the underscore character and then store back into a different variable $string2...

Could anyone give me a point in the right direction?

Cheers
You should take a look at str_raplace() function.
- [url=http://php.belnet.be/manual/en/function.str-replace.php]http://php.belnet.be/manual/en/function.str-replace.php[/url]

str_replace --  Replace all occurrences of the search string with the replacement string

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.