I currently have a really great preg_replace
system going on for my seo needs, but I’m having trouble with one character specifically and that’s the $. The code I have returns the $ as a blank but I would prefer it if it turned the $ to the letter S. It’s probably just a minor tweak but I’m sure how to single it out.
$urlname = preg_replace("/[^a-zA-Z0-9/_|+ -]/", '', $info['name']);
$urlname = strtolower(trim($urlname, '-'));
$urlname = preg_replace("/[/_|+ -]+/", '-', $urlname);
$seourl = strtolower($urlname);
3
Answers
I was overthinking it. I should have changed it before I stripped out all the other special characters. Thanks, Siddhu Siddhartha Roy.
you can use,
strtr
See Demo Here