Array ( [b] => Array"/> Array ( [b] => Array">
Maison >développement back-end >tutoriel php >php 数组相加,看不懂,请些一个好例子给小弟我看一下好吗
php 数组相加,看不懂,请些一个好例子给我看一下好吗
$a ="a";<br />$b ="b";<br />$ay[$a][$b][]= 3;<br />print_r($ay);<br />
<br />/** <br /> * 返回数组的维度 <br /> * @param [type] $arr [description] <br /> * @return [type] [description] <br /> */<br />function arrayLevel($arr){ <br /> $al = array(0); <br /> function aL($arr,&$al,$level=0){ <br /> if(is_array($arr)){ <br /> $level++; <br /> $al[] = $level; <br /> foreach($arr as $v){ <br /> aL($v,$al,$level); <br /> } <br /> } <br /> } <br /> aL($arr,$al); <br /> return max($al); <br />} <br /><br />$arr = array( <br /> '0'=>'0', <br />); <br /><br />echo arrayLevel($arr); <br />
$Me = array(<br /> array(1, 2, 3, 4),<br /> array(4, 6, 7, 8),<br /> array(9, 10, 11, 12),<br /> array(13, 14, 15, 16),<br />);<br />$a = 0;<br />$b = 1;<br />$k = 2;<br />$c = 3;<br />$z = 3;<br />$m = 3;<br />$sy = 1;<br />$my = 2;<br />$Me[$a][$b] += $Me[$k][$c];<br />$Me[$z][$m] = $Me[$sy][$my];<br />print_r($Me);