How to replace two different characters with one character using preg_replace() function?
There is no need to use preg_replace
.
Use str_replace
instead:
$output = str_replace(array('@', '.'), '-', $input);
Since your search patterns are just strings, using string replacement using str_replace
is better as suggested in other answer.
Here goes the preg_replace
based answer:
$str = preg_replace('/@|\./','-',$str);