CodeIgniter Forums
Message: Wrong parameter count for preg_replace() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Message: Wrong parameter count for preg_replace() (/showthread.php?tid=32619)



Message: Wrong parameter count for preg_replace() - El Forum - 07-28-2010

[eluser]Unknown[/eluser]
I found a Google result on a Drupal topic regarding this error, but nothing in respect to Codeigniter. This expression pulls no errors in a non-CI instance, but gets errors thrown a few times in CI (it's a loop). It still outputs the right array...what is the issue?

Message: Wrong parameter count for preg_replace() for ->this line


Code:
$regexp="<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
    preg_match_all("/$regexp/siU", $input, $matches);
    //echo "Preg Match Links";
    //print_r($matches[0]);
    //echo "<br/><br/>";

    $outputArray=array();
    $postID=array();
    $i=0;
             foreach ($matches[0] as $key=>$value):
               $stripped[$i] = preg_replace($matches[0][$i]);
->this line    preg_match("/$regexp/siU", $value, $outputArray);
....


Message: Wrong parameter count for preg_replace() - El Forum - 07-28-2010

[eluser]Federico BaƱa[/eluser]
I can only think of $value being empty.

EDIT:

The third parameter is the string or array of strings where to look, you're there putting an empty array. That may be the issue.

http://php.net/manual/en/function.preg-replace.php

also I read around that it has something related to the PHP version you're on, not sure


Message: Wrong parameter count for preg_replace() - El Forum - 07-28-2010

[eluser]pickupman[/eluser]
You are missing 2nd and 3rd parameters
preg_replace ( mixed $pattern , mixed $replacement , mixed $subject);