我正在使用多维数组; 我使用arsort函数来获取已添加最新的数组。当我想使用这个数组我做的这一切工作正常PHP多维数组键值
arsort($this->shoppingBag);
$this->productToShow = key($this->shoppingBag);
:
$prodName = key($this->shoppingBag[$this->productToShow]);
这给了我,我需要正确的名称正确的产品。当我做
$count = $this->shoppingBag[$this->productToShow[$prodName]];
它给了我一个“未定义的索引”的错误。
当我回声钥匙作为字符串我从阵列得到正确的值数组..
这是为什么,我怎么能得到与该键的值?
编辑:
array(4)
{
[38] => array(1)
{
["SAMSUNG LE32D450"] => int(3)
}
[32] => array(1)
{
["Inspiron 15R"] => int(1)
}
[29] => array(1)
{
["XPS 15"] => int(25)
}
[37] => array(1)
{
["Logitech M185 Black"] => int(10)
}
}
您能否包含多维数组数据的示例? –
是的,现在包含数组。 – kendepelchin
检查我最近的编辑。我很确定这应该工作。 –