0

i have the following code:

    return preg_replace_callback("#\{gallery: '(.+?)'(?: dir: ([0-1]))?\}#i", create_function('$i', '$dir = isset( $i[2] ) ? 1 : 0; $oGallery = new Gallery( $i[1] ) ; $oGallery->PublicSide($dir);' ), $string);

the problem is that this works on my localhost (PHP5.3) but when i upload it to my server (5.2.17) it doesnt.. any ideas why? seems to have something to do with the single quotes on "#\{gallery: '(.+?)'(?: dir: ([0-1]))?\}#i"

Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
Waldir Bolanos
  • 422
  • 3
  • 7
  • 1
    Define "it doesn't work"? What does the function call return? – Bailey Parker Jul 17 '12 at 04:07
  • It just returns the full original string, as if it didn't find any matches in this case: {gallery: 'images/'} or {gallery: 'images/' dir: 1} – Waldir Bolanos Jul 17 '12 at 04:08
  • Have you read through the PHP docs of this function? It's behaviour may be different between PHP 5.3 and 5.2.x http://php.net/manual/en/function.preg-replace-callback.php – Jessedc Jul 17 '12 at 04:23

1 Answers1

2

You aren't actually returning anything from your callback, so it's not going to make any replacements. Maybe you meant to do this, instead?

... return $oGallery->PublicSide($dir); ...
FtDRbwLXw6
  • 27,774
  • 13
  • 70
  • 107