-3

I have this error when I try to execute my php code:

Parse error: syntax error, unexpected '&' in /opt/lampp/htdocs//app/engine.class.php on line 34

private function setMatches($doc)
{
    $strMatches = array();
    $positions = $this->getPositions($doc);

    foreach ($positions as $v)
    {
        $start = $v;
        $end = 1;
        $v++;
        while ($end !== 0)
        {
            if (preg_match("/^<div/", &$doc[$v]))
                $end++;
            else if (preg_match("/^<\/div/", &$doc[$v]))
                $end--;
            $v++;
        }
        $end = $v - 1;
        $strMatches[] = substr($doc, $start, $end - $start);
    }
    print_r($strMatches);
}

So, here I try to get the address of the character, to pass it in the preg match function as a string. i dont get it, any idea?

Panda
  • 6,955
  • 6
  • 40
  • 55
Alex Trupin
  • 113
  • 2
  • 7

1 Answers1

2

Call time pass by reference has been removed in PHP. So I'm guessing where you're pre-pending & to $doc generates a syntax error. Remove those &s.

Unix One
  • 1,151
  • 7
  • 14