alex alex - 1 year ago 120
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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download