php array is as follows
array(6) {
[17]=>
array(1) {
[0]=>
string(1) "1"
}
[11]=>
array(1) {
[0]=>
string(1) "2"
}
[10]=>
array(1) {
[0]=>
string(1) "6"
}
[9]=>
array(1) {
[0]=>
string(1) "1"
}
}
How does the above array become the following one?
[['17','1'],['11','2'],['10','6'],['9','1']]
谢谢大神
The answers given by the respondents above are all quite good, and I can’t help but express my ugliness
It’s actually quite simple. The answer won’t be much different, so I’ll simply add some explanations
First of all, you need to learn to traverse foreach, and then PHP is a weakly typed language, and the variable type is converted by itself
Oh yes, the other thing you need to know is $arr[] = $var, which is like adding elements to the end of an array. Another method is array_push($arr, $var), but this method is less efficient than the first one