为什么使用两个数组(数组数组)作为值的list()
方法不起作用(对于一个特定数组($ subCategories),另一个数组中的列表换行,另一个数组在list()之前输出等于)。
列表方法:
list($subCategories, $subCategoriesName) = [$subCategories, $subCategoriesName]; //[array, array]
[$subCategories, $subCategoriesName]
是函数的返回
列表前的$ subCategories
array(4) {
[0]=>
array(3) {
["id"]=>
int(1)
["sub_category_name"]=>
string(14) "Industrilizado"
["category_id"]=>
int(1)
}
[1]=>
array(3) {
["id"]=>
int(2)
["sub_category_name"]=>
string(9) "In natura"
["category_id"]=>
int(1)
}
[2]=>
array(3) {
["id"]=>
int(3)
["sub_category_name"]=>
string(13) "Comida pronta"
["category_id"]=>
int(1)
}
[3]=>
array(3) {
["id"]=>
int(4)
["sub_category_name"]=>
string(11) "Desidratado"
["category_id"]=>
int(1)
}
}
列表后的$ subCategories
array(1) {
[0]=>
array(4) {
[0]=>
array(3) {
["id"]=>
int(1)
["sub_category_name"]=>
string(14) "Industrilizado"
["category_id"]=>
int(1)
}
[1]=>
array(3) {
["id"]=>
int(2)
["sub_category_name"]=>
string(9) "In natura"
["category_id"]=>
int(1)
}
[2]=>
array(3) {
["id"]=>
int(3)
["sub_category_name"]=>
string(13) "Comida pronta"
["category_id"]=>
int(1)
}
[3]=>
array(3) {
["id"]=>
int(4)
["sub_category_name"]=>
string(11) "Desidratado"
["category_id"]=>
int(1)
}
}