php入門–array_walk_recursiveの使い方

array_walk_recursive — 配列の全ての要素に、ユーザー関数を再帰的に適用する

phpコード:
$arr = array(
'name’=>’tom’,
'age’=>’26’,
'update’=>’1000167282’,

);

function arrsearch(&$item,$key)
{
if($key == 'update’)
{
$item = date('Y-m-d’,$item);
}
}
array_walk_recursive($arr,"arrsearch");
print_r($arr);

実行結果
Array ( [name] => tom [age] => 26 [update] => 2001-09-11 )

PHP

Posted by arkgame