Edit report at https://bugs.php.net/bug.php?id=30627&edit=1
ID: 30627 Updated by: ni...@php.net Reported by: e...@php.net Summary: A "userdata" parameter for preg_replace_callback -Status: Open +Status: Wont fix Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: As we now have closures this isn't necessary anymore (as you can just use() the additional parameters). Previous Comments: ------------------------------------------------------------------------ [2004-11-06 17:49:02] e...@php.net The last parameter has to be $things, of course. ------------------------------------------------------------------------ [2004-10-31 14:01:05] e...@php.net 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 https://bugs.php.net/bug.php?id=30627&edit=1