1

I need to replace ereg_replace with preg_replace but there is something in the syntax that I obviously don't understand as I'm unable to make it work. I've read all that I can find but to no avail. Any help would be appreciated. The code I need to convert is as follows:

$qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']);
talkpoppycock
  • 147
  • 1
  • 9
  • 1
    And what did you try replacing that with? – Patrick Q Aug 29 '14 at 15:14
  • I tried a number of permutations, but:$qstr = preg_match("/&page=[0-9]+/", "",$_SERVER['QUERY_STRING']);seemed the correct version. – talkpoppycock Aug 29 '14 at 15:24
  • You have `preg_match` there, not `preg_replace`. See it working just fine with `preg_replace` [here](http://sandbox.onlinephpfunctions.com/code/2df63ea6966ecfecf39ea87258b1d3bfe44837b4). – Patrick Q Aug 29 '14 at 15:34
  • @Patrick Q I can't believe I did that! Little wonder it didn't work when I was that stupid - Sorry. – talkpoppycock Aug 29 '14 at 15:40

0 Answers0