I want to run this PHP function —
$querystring_arr='maxResults=50&startIndex=50&sort=date';
$str=preg_replace("(&startIndex=)?[0-9]*(&)?","&startIndex=".$sindex."&",$querystring_arr);
When I print $str it gives the error:
Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in C:\xampp\htdocs\myapp\paginator.class.php on line 112
Please, where is my regular expression wrong?
You need to wrap you regex with delimiters.
Alternatively, don’t use a regex and use what PHP provides.