alex alex - 9 months ago 94
PHP Question

Replacing Spaces with Underscores

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


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 Source
$name = str_replace(' ', '_', $name);