Req #30627 [Opn->Wfx]: A "userdata" parameter for preg_replace_callback

From: Date: Sun, 17 Feb 2013 13:18:10 +0000
Subject: Req #30627 [Opn->Wfx]: A "userdata" parameter for preg_replace_callback
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-176684@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=30627&edit=1 ID: 30627 Updated by: nikic@php.net Reported by: et@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] et@php.net The last parameter has to be $things, of course. ------------------------------------------------------------------------ [2004-10-31 14:01:05] et@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

« previous php.bugs (#176684) next »