php replace space and dash with underscore code example
Example 1: php replace space with underscore
$str = str_replace(' ', '_', $str);
Example 2: php replace spaces with dash
str_replace(' ', '-', $string);
$str = str_replace(' ', '_', $str);
str_replace(' ', '-', $string);