alex alex - 7 months ago 89
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?

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