php replace spaces with dash code example Example: php replace spaces with dash str_replace(' ', '-', $string);