phppreg-replaceereg-replace

What to change from ereg_replace to preg_replace?


I've just upgraded to php 5.4 and I've come across a common error of needing to upgrade my ereg_replace to preg_replace, but I'm a tad confused.

How can I change the following ereg_replace to a preg_replace?

ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']);

Solution

  • Try this one:

    preg_replace("/&page=[0-9]+/","",$_SERVER['QUERY_STRING']);

    Hope this helps :)