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) "Never Say Goodbye"
}
[2]=>
Array (2) {
[0]=>
String (12) "201410090345"
[1]=>
String (4) "Girlfriends"
}
But the subscript is 0, 1, 2. Now I want to change the subscript to the content of the first column of this two-dimensional data.
For example, the subscript of the first line becomes 201410090343, the second line becomes 201410090344, and the third line becomes 201410090345.
How is this supposed to be done? Thank you
Reply to discussion (solution)
$a = Array (" 201410090343", "American Scam"), Array ( "201410090344", "no longer say break up"), Array ("201410090345", "girlfriends"), ), foreach ($a as $v) $b [$v [0]] = $v; $a = $b; Var_dump ($a);
Array (3) { ["201410090343"]=> Array (2) { [0]=> string () "201410090343" [1]=> String (8) "American Scam" } ["201410090344"]=> Array (2) { [0]=> string (12) "201410090344" [1]=> String (10) "No longer say break Up" } ["201410090345"]=> Array (2) { [0]=> String ("201410090345" [1]=> string (4) "Girlfriends" }
$list 1 = Array (
Array ("201410090343", "American Scam"), Array ("201410090344", "no longer say break up"), Array ("201410090345", "girlfriends"),
);
$list 2 = array ();
foreach ($list 1 as $key = = $val) {
$list 2[$val [0]] = $val;
}
Echo '
';
Print_r ($list 2);
?>