ID: 30627 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Feature/Change Request Operating System: Irrelevant PHP Version: Irrelevant New Comment:
The last parameter has to be $things, of course. Previous Comments: ------------------------------------------------------------------------ [2004-10-31 14:01:05] [EMAIL PROTECTED] Description: ------------ It would be nice if preg_replace_callback had a "userdata" parameter. Example: $string = "[thing 1] foo [thing 2]"; $things = array( 1 => "One thing", 2 => "Other thing"); function replace_callback($match, $data) { return $data[$match[1]]; } echo preg_replace_callback('/\[thing (\d+)\]/', 'replace_callback', $string, -1, $data); Would Output: One thing foo Other thing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30627&edit=1