How to classify the following arrays $ t2 = Array (& nbsp; [Nanchang] & nbsp ;=& gt; & nbsp; Array & nbsp; & nbsp; (& nbsp; & n how to classify and count the following arrays
$ 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. Share :? Array ???????? (???????????? [Excellent]? =>? 1 ???????????? [Good]? =>? 1 ????????)... 'Data-pics = ''>
------ 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 );