I am trying to do a PHP replace like ASP Replace. The function just returns a blank value though?
$zonename=mysql_real_escape_string($_POST["zonename"]);
$zname_clean =""; # blank string
$zname_clean = $zonename; # fill string with the post form
$zname_clean = str_replace($zname_clean, " ", ""); # remove white space
That is my code. Example Zonename would be “Header Left”, I want to remove capitalization and also remove whitespace.
How can I remove whitespace and convert the case and also is there a cleaner way of doing this?
See the PHP manual for
strtolower()andpreg_replace().