1--TEST-- 2Bug #37911 (preg_replace_callback ignores named groups) 3--FILE-- 4<?php 5 6function callback($match) 7{ 8 var_dump($match); 9 return $match[1].'/'.strlen($match['name']); 10} 11 12var_dump(preg_replace_callback('|(?P<name>blub)|', 'callback', 'bla blub blah')); 13 14var_dump(preg_match('|(?P<name>blub)|', 'bla blub blah', $m)); 15var_dump($m); 16 17var_dump(preg_replace_callback('|(?P<1>blub)|', 'callback', 'bla blub blah')); 18 19?> 20--EXPECTF-- 21array(3) { 22 [0]=> 23 string(4) "blub" 24 ["name"]=> 25 string(4) "blub" 26 [1]=> 27 string(4) "blub" 28} 29string(15) "bla blub/4 blah" 30int(1) 31array(3) { 32 [0]=> 33 string(4) "blub" 34 ["name"]=> 35 string(4) "blub" 36 [1]=> 37 string(4) "blub" 38} 39 40Warning: preg_replace_callback(): Compilation failed: group name must start with a non-digit at offset %d in %sbug37911.php on line %d 41NULL 42