PHP replace spaces, comma's, dashs and ! with forward slashes

php

Solution

Regular expression-free example:

$str = str_replace([' ', ',', '-', '!'], '/', '& String! - !');
$str = str_replace('&', 'and', $str);
echo $str;

Problem

So far I have : ``` $q = str_replace(' ','/',$q); $q = str_replace(',','/',$q); $q = str_replace('\-','/',$q); ``` but I'm not sure what I'm doing wrong because none of the PHP sites that explain the functions, include an example of every character to search for. Note, I only want it to replace spaces, comma's ',' dashes '-', '!' with forward slashes and then another replace function to replace any '&' with 'and'.

Original source