alex alex - 1 month ago 20
PHP Question

Replacing Spaces with Underscores

I have a PHP Script that users will enter a name like:

Alex_Newton
,

However, some users will use a space rather than an underscore, so my question is:

How do I auto-replace spaces with Underscores in PHP?

Answer
$name = str_replace(' ', '_', $name);