note 60447 added to function.preg-replace-callback
| From: | php-general at lists dot php dot net | Date: | Sat, 07 Jan 2006 07:55:52 +0000 |
| Subject: | note 60447 added to function.preg-replace-callback | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101337@lists.php.net to get a copy of this message | ||
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);
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace-callback.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60447
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60447&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60447&report=yes
Search -- http://master.php.net/manage/user-notes.php