note 60447 deleted from function.preg-replace-callback by colder

From: Date: Mon, 18 Jun 2007 18:45:37 +0000
Subject: note 60447 deleted from function.preg-replace-callback by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127657@lists.php.net to get a copy of this message
Note Submitter: ---- I've found php will crash when I store a reference to the $match parameter but there's an easy work around... $mylist=array(); function my_callback($match) { global $mylist; // this crashes PHP... // $mylist[]=$match; // this copies the $match array so is safe $mylist[]=array_merge($match); return 1; } $subject="The rain in Spain falls mainly on the plane."; echo "<p>".preg_replace_callback("/[aeiou]/i", "my_callback", $subject); echo "<p>"; print_r($mylist);

« previous php.notes (#127657) next »