How to change the value of an array into a health name to form a new array.
This post was last edited by xuexi123abc163 on 2014-11-24 11:40:57
(
[0] = = Array
(
[AK] = 1
[FS] = 12
[TSS] = SD third party f
)
[1] = = Array
(
[AK] = 2
[FS] = 12
[TSS] = yes, it happens.
)
[2] = = Array
(
[AK] = 3
[FS] = 22
[TSS] = good new play
)
[3] = = Array
(
[AK] = 4
[FS] = 22
[TSS] = eight real score
)
[4] = = Array
(
[AK] = 6
[FS] = 22
[TSS] = eight real score
)
)
The above array is $ABC
I coccineus want to form a new array to put the value of FS as the key name, and then put the values of FS the same, forming a new array,.
The array is as follows:
(
[+] = Array
(
[0] = = Array
(
[AK] = 2
[TSS] = yes, it happens.
)
[1] = = Array
(
[AK] = 2
[TSS] = yes, it happens.
)
)
[+] = Array
(
...............
)
)
------to solve the idea----------------------
$ar = Array (
Array (
' ak ' = ' 1 ',
' fs ' = ' + ',
' tss ' = ' + ' SD third Square f ',
),
Array (
' ak ' = ' 2 ',
' fs ' = ' y ',
' tss ' = ' occurs ',
),
Array ( ' ak ' = ' 3 ',
' fs ' + ', '
' tss ' = ' good new play ',
,
Array (
' ak ' = ' 4 ',
' FS ' = ' + ',
' TSS ' + ' eight real scores ',
,
Array (
' ak ' = ' 6 ',
' fs ' = ', '
' t SS ' = ' Eight real scores ',
),
);
$res = Array ();
foreach ($ar as $r) {
$t = $r [' FS '];
unset ($r [' FS ']);
$res [$t] = $r;
}
Print_r ($res);
Array
(
[+] = Array
(
[0] = = Array
(
[AK] = 1
[TSS] = SD third party f
)
[1] = = Array
(
[AK] = 2
[TSS] = yes, it happens.
)
)
[+] = Array
(
[0] = = Array
(
[AK] = 3
[TSS] = good new play
)
[1] = = Array
(
[AK] = 4
[TSS] = eight real score
)
[2] = = Array
(
[AK] = 6
[TSS] = eight real score
)
)
)