$t2=Array
(
[南昌] => Array
(
[优秀] => 1
[良好] => 1
)
[赣州] => Array
(
[优秀] => 2
)
[九江] => Array
(
[良好] => 1
[差等] => 1
)
)
南昌,赣州 九江优秀的数目统计。(根据$t2去计算优良差的个数)
优秀的数组如下
$t2_yx=Array ( 0 => '1', 1 => '2', 2 => '0' );
良好的数组如下
$t2_lh=Array ( 0 => '1', 1 => '0', 2 => '1' );
差等的数组如下
$t2_cd=Array ( 0 => '0', 1 => '0', 2 => '1' );
http://bbs.csdn.net/topics/390628423
或者看这个。
学过php不该不会呀。
$good = array();$ok = array();$bad = array();foreach( $t2 as $k => $v ){ $good[$k] = $v["优秀"] ? $v["优秀"] : 0 ; $ok[$k] = $v["良好"] ? $v["良好"] : 0 ; $bad[$k] = $v["差等"] ? $v["差等"] : 0 ;}print_r( $good );print_r( $ok );print_r( $bad );