<?php
$arr = array(array(1,2), array(3, 4), array(array(5, 6), array(7,
8)));
function t($a)
{
if(is_array($a))
{
foreach($a as $k=>$v)
{
$a[$k] = t($v);
}
}else{
$a =
$a*10;
}
return $a;
}
$ab =
t($arr);
// 此时数组的每个元素都乘了 10 了
print_r($ab);
// 结果为
Array
(
[0] => Array
(
[0] => 10
[1] => 20
)
[1] => Array
(
[0] => 30
[1] => 40
)
[2] => Array
(
[0] => Array
(
[0] => 50
[1] => 60
)
[1] => Array
(
[0] => 70
[1] => 80
)
)
)
?>