我得到了一个具有这种结构的数组,我试图从中获取一个元素:
Array
(
[0] => Array
(
[description] =>
[idProduct] => Array
(
[id1] => 7227
[idProduct] => 3
)
[idSite] => 2592
[name] => Parcela Azul
[picture] =>
)
[1] => Array
(
[description] =>
[idProduct] => Array
(
[id1] => 7227
[idProduct] => 8
)
[idSite] => 2592
[name] => Apartamento 2 pax
[picture] =>
)
)
所以,我得到了一个存储数组的变量。我的问题是:
为什么这样有效:
$test = $categorias[0];
$test2 = $test['name'];
echo "<pre>";
print_r($test2);
echo "</pre>";
结果:Parcela Azul
这不会:
$test = $categorias[0]['name'];
echo "<pre>";
print_r($test);
echo "</pre>";