1--TEST-- 2mb_ereg_replace_callback() 3--EXTENSIONS-- 4mbstring 5--SKIPIF-- 6<?php 7function_exists('mb_ereg_replace_callback') or die("skip mb_ereg_replace_callback() is not available in this build"); 8?> 9--FILE-- 10<?php 11$str = 'abc 123 #",; $foo'; 12 13echo mb_ereg_replace_callback('(\S+)', function ($m) { 14 return $m[1].'('.strlen($m[1]).')'; 15}, $str), "\n"; 16 17echo mb_ereg_replace_callback('(?<word>\w+) (?<digit>\d+).*', function ($m) { 18 return sprintf("%s-%s", $m['digit'], $m['word']); 19}, $str), "\n"; 20?> 21--EXPECT-- 22abc(3) 123(3) #",;(4) $foo(4) 23123-abc 24