How to convert the value of the array into the health name to form a new array. This post was last edited by xuexi123abc163 from 2014-11-2411: 40: 57 (& nbsp; [0] & nbsp; & gt; & nbsp; Array & nbsp; & How does nb convert the value of an Array into a new Array by name.
This post was last edited by xuexi123abc163 at 11:40:57
(
[0] => Array
(
[Ak] => 1
[Fs] => 12
[Tss] => sd third-party f
)
[1] => Array
(
[Ak] => 2
[Fs] => 12
[Tss] => Yes
)
[2] => Array
(
[Ak] => 3
[Fs] => 22
[Tss] => Good News
)
[3] => Array
(
[Ak] => 4
[Fs] => 22
[Tss] => octal score
)
[4] => Array
(
[Ak] => 6
[Fs] => 22
[Tss] => octal score
)
)
The above array is $ abc
I want to form a new array, take the fs value as the key name, and then use the same fs value to form a new array ,..
The array is as follows:
(
[12] => Array
(
[0] => Array
(
[Ak] => 2
[Tss] => Yes
)
[1] => Array
(
[Ak] => 2
[Tss] => Yes
)
)
[22] => Array
(
...............
)
)
------ Solution ----------------------
$ Ar = array (
Array (
'AK' => '1 ',
'Fs' => '12 ',
'Oss '=> 'SD third-party f ',
),
Array (
'AK' => '2 ',
'Fs' => '12 ',
'Tss' => 'Yes ',
),
Array (
'AK' => '3 ',
'Fs' => '22 ',
'Oss '=> 'New play ',
),
Array (
'AK' => '4 ',
'Fs' => '22 ',
'Tss' => 'eight real rating ',
),
Array (
'AK' => '6 ',
'Fs' => '22 ',
'Tss' => 'eight real rating ',
),
);
$ Res = array ();
Foreach ($ ar as $ r ){
$ T = $ r ['Fs'];
Unset ($ r ['Fs']);
$ Res [$ t] [] = $ r;
}
Print_r ($ res );
Array
(
[12] => Array
(
[0] => Array
(
[Ak] => 1
[Tss] => sd third-party f
)
[1] => Array
(
[Ak] => 2
[Tss] => Yes
)
)
[22] => Array
(
[0] => Array
(
[Ak] => 3
[Tss] => Good News
)
[1] => Array
(
[Ak] => 4
[Tss] => octal score
)
[2] => Array
(
[Ak] => 6
[Tss] => octal score
)
)
)