unistake Posted November 11, 2010 Share Posted November 11, 2010 Hi all, I need to remove any '-' character from a user input in a html form. How can I get rid of this character? e.g. $var = A-1DAS $var1 = strtolower($var); I need the output as 'a1das' Link to comment https://forums.phpfreaks.com/topic/218376-removing-a-particular-character-from-a-variable/ Share on other sites More sharing options...
revraz Posted November 11, 2010 Share Posted November 11, 2010 http://php.net/manual/en/function.str-replace.php Link to comment https://forums.phpfreaks.com/topic/218376-removing-a-particular-character-from-a-variable/#findComment-1132989 Share on other sites More sharing options...
unistake Posted November 11, 2010 Author Share Posted November 11, 2010 Thanks, Can this be simplified? $dash = "-"; $dir_temp = str_replace($dash, "", $reg); $directory = strtolower($dir_temp); Link to comment https://forums.phpfreaks.com/topic/218376-removing-a-particular-character-from-a-variable/#findComment-1132992 Share on other sites More sharing options...
revraz Posted November 11, 2010 Share Posted November 11, 2010 $reg = "1-2-3"; $directory = strtolower(str_replace("-","",$reg)); echo $directory; Link to comment https://forums.phpfreaks.com/topic/218376-removing-a-particular-character-from-a-variable/#findComment-1132999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.