<?php
$r1=array("n"=>3,"ni"=>2,["nis"=>3,[["nish"=>4],[["nishi"=>"n"],[["nishi"=>true]]]]]);
echo "<pre>";
//print_r($r1);
echo "</pre>";
$sum=0;
for ($i=0;$i<count($r1);$i++) {
$curr=$r1[$i];
if (is_array($curr)) {
$sum += array_sum($curr);
} else if (is_numeric($curr)) {
$sum += $curr;
}
echo $sum;
}
?>
我试图找到数组中值的总和并留下字符串。如果有人知道答案请帮忙