$subject_array ポインタの位置は preg_replace_callback のコールバック関数でどのように決定されますか? つまりテンキーとは?例えば
$final_array = preg_replace_callback("/pattern/",
create_function(
'$matches',
'[WHAT IS MY ARRAY POSITION? ($foo = ...)]; return $foo);'
), $subject_array);
編集
Foo、Bar、baZが欲しい。以下は機能しません。
$rgData = array('foo', 'bar', 'baz');
$rgData = preg_replace_callback('/(\w)(\w)(\w)/',
function($rgMatches) use (&$rgData)
{
var_dump(key($rgData));//see this debug
next($rgData);
if (key($rgData)==2) {
return strtoupper($rgMatches[2]);
} else {
return strtoupper($rgMatches[0]);
}
}, $rgData);
var_dump($rgData);//see this debug
または、もっと簡単に言うと、Foo、bAr、baZ が必要です。
$rgData = array('foo', 'bar', 'baz');
$rgData = preg_replace_callback('/(\w)(\w)(\w)/',
function($rgMatches) use (&$rgData)
{
var_dump(key($rgData));//see this debug
next($rgData);
return strtoupper($rgMatches[key($rgData)]);
}, $rgData);
var_dump($rgData);//see this debug