PHP Question

Replace '_' in PHP

I've made a register system in PHP. The user name can only be something like this:


I need to delete the
from the string and special characters like

Does anyone know a function for this?

Answer Source should be the one you need you can find additional examples at the link

// Provides: <body text='black'>
$bodytag = str_replace("%body%", "black", "<body text='%body%'>");

// Provides: Hll Wrld f PHP
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

// Provides: You should eat pizza, beer, and ice cream every day
$phrase  = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy   = array("pizza", "beer", "ice cream");

$newphrase = str_replace($healthy, $yummy, $phrase);

// Provides: 2
$str = str_replace("ll", "", "good golly miss molly!", $count);
echo $count;

using your string

<?php $myString = 'somestring_with_under_scores';
 $newString = str_replace('_', '' , $myString);//remove '_'
 echo $newString;?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download