Is this preg_replace correct ?
The HTML5 validator doesn't like '&' in the urls it wants '&'
so I am trying to change them before they get output from the server.
I can not stop users from pasting if urls with '&' in them so I just want to swap them out.
Because I only want to change '&' that are in urls - not anywhere else
I need to match a pattern.
So I have my preg_replace like this:
Dunno why - just doesn't look right
Hopefully I will get the hang of this one day !!
wouldn't str_replace Be a lot easier?
str_replace('&', '&', 'http://www.example.com/search.php?query=Hello&world&this&is&a&test');
You could test your regular expression online using testers like http://gskinner.com/RegExr/
Originally Posted by jeddik
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)