Page 1 of 1

changing whitespace to underscore

Posted: Sat Oct 29, 2005 6:42 pm
by Sequalit
How would I go about altering my string from

user name

to

user_name

?

Posted: Sat Oct 29, 2005 6:52 pm
by elecktricity
make sure it's in a variable and do this:

Code: Select all

<?PHP
$msg = str_replace(" ", "_", $msg);
?>

Posted: Sat Oct 29, 2005 9:01 pm
by Sequalit
okay cool thanks, silly me was trtying to use preg_replace()