How to classify and calculate the following Array $ t2 = Array
(
[Nanchang] => Array
(
[Excellent] => 1
[Good] => 1
)
[Ganzhou] => Array
(
[Excellent] => 2
)
[Jiujiang] => Array
(
[Good] => 1
[Poor] => 1
)
)
Statistics on excellent quantity of Jiujiang in Nanchang and Ganzhou. (Calculate the number of excellent differences based on $ t2)
An excellent array is as follows:
$ T2_yx = Array (0 => '1', 1 => '2', 2 => '0 ');
A good array is as follows:
$ T2_lh = Array (0 => '1', 1 => '0', 2 => '1 ');
And other arrays are as follows:
$ T2_cd = Array (0 => '0', 1 => '0', 2 => '1 ');
Http://bbs.csdn.net/topics/390628423
Or read this.
Reply to discussion (solution)
Shouldn't I have learned php.
$ Good = array (); $ OK = array (); $ bad = array (); foreach ($ t2 as $ k => $ v) {$ good [$ k] = $ v ["excellent"]? $ V ["excellent"]: 0; $ OK [$ k] = $ v ["good"]? $ V ["good"]: 0; $ bad [$ k] = $ v ["poor"]? $ V ["poor"]: 0;} print_r ($ good); print_r ($ OK); print_r ($ bad );