#30627 [Opn]: A "userdata" parameter for preg_replace_callback

From: Date: Sat, 06 Nov 2004 16:49:03 +0000
Subject: #30627 [Opn]: A "userdata" parameter for preg_replace_callback
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68759@lists.php.net to get a copy of this message
ID: 30627 User updated by: et@php.net Reported By: et@php.net 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] 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 http://bugs.php.net/?id=30627&edit=1

« previous php.bugs (#68759) next »