日期:2014-05-17 浏览次数:20647 次
$arr=array( array('3','-1','4','2','-2'), array('-3','-1','-4','-12','-2','21','13','-16'), array('-5','-8','4','2') ); foreach($arr as $k=>$a) { $n = count(array_keys(array_map('sign',$a), -1)); $r[$k] = array('+' => count($a) - $n, '-' => $n); } print_r($r); function sign($n) { return $n/abs($n); }