Php 如何在数组中引用值

Php 如何在数组中引用值,php,arrays,Php,Arrays,我不知道如何引用数组中的a值 如果我像这样显示数组: while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { print_r( $this->contents[$products_id]['attributes']); echo "<br/>"; } 我需要的值是17 这很有效,谢谢!现在来看,很明显。我以为115和[2]是相连的。为什么使用

我不知道如何引用数组中的a值

如果我像这样显示数组:

 while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
     print_r( $this->contents[$products_id]['attributes']); echo "<br/>";   
}

我需要的值是17

这很有效,谢谢!现在来看,很明显。我以为115和[2]是相连的。为什么使用旧的PHP4方法来通过数组(使用
列表
+
每个
)?即使对于这个问题,你甚至不应该考虑做这种事情。你能解释一下吗?这不是我的代码。新方法是什么?我应该说,php5处理数组的方法是什么?为什么这种方法如此糟糕?您必须使用
foreach
关键字:
foreach($container as$key=>$value){/*actions*/}
(这里是一行,因为在so注释上,您不能粘贴多行代码;)。这是一个循环,在每次转动时,
$key
将是当前元素的键(相当于
列表的第一个参数),而
$value
将是其值(第二个参数)。
$this->contents[$products_id]['attributes'][2]
$this->contents[$products_id]['attributes'][2]