How can I change the subscript of an existing array? There is such a two-dimensional array
[0] =>
Array (2 ){
[0] =>
String (12) 201410090343"
[1] =>
String (8) "American Scam"
}
[1] =>
Array (2 ){
[0] =>
String (12) 201410090344"
[1] =>
String (10) "do not say break up"
}
[2] =>
Array (2 ){
[0] =>
String (12) 201410090345"
[1] =>
String (4) "girlfriends"
}
The subscript is 0, 1, and 2. Now I want to change the subscript to the first column of the two-dimensional data.
For example, the subscript of the first row is 201410090343, the subscript of the second row is 201410090344, and the subscript of the third row is 201410090345.
What should I do? Thank you.
Reply to discussion (solution)
$ A = array ("201410090343", "American scam"), array ("201410090344", "do not say break up"), array ("201410090345 ", "Girlfriends"),); foreach ($ a as $ v) $ B [$ v [0] = $ v; $ a = $ B; var_dump ($ );
Array (3) {["201410090343"] => array (2) {[0] => string (12) "201410090343" [1] => string (8) "U.S. scam"} ["201410090344"] => array (2) {[0] => string (12) "201410090344" [1] => string (10) "Do not say breaking up"} ["201410090345"] => array (2) {[0] => string (12) "201410090345" [1] => string (4) "Girlfriends "}}
$ List1 = array (
Array ("201410090343", "American scam"), array ("201410090344", "do not say break up"), array ("201410090345", "Girlfriends "),
);
$ List2 = array ();
Foreach ($ list1 as $ key => $ val ){
$ List2 [$ val [0] = $ val;
}
Echo'
';
Print_r ($ list2 );
?>