changing whitespace to underscore

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sequalit
Forum Commoner
Posts: 75
Joined: Wed Oct 12, 2005 9:57 pm
Location: Texas

changing whitespace to underscore

Post by Sequalit »

How would I go about altering my string from

user name

to

user_name

?
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

make sure it's in a variable and do this:

Code: Select all

<?PHP
$msg = str_replace(" ", "_", $msg);
?>
Sequalit
Forum Commoner
Posts: 75
Joined: Wed Oct 12, 2005 9:57 pm
Location: Texas

Post by Sequalit »

okay cool thanks, silly me was trtying to use preg_replace()
Post Reply