2
为了简化这个问题,假定每个单元格都有一个行名和一个列名,可以将您正确地映射到适当的单元格。我正在循环访问数据库记录,并为2D数组中的某些字段创建位置,以便返回给调用者。我的问题是如何判断一个单元格是否已经存在于数组[rownName] [colName]?如何判断一个特定的关键组合是否已经在PHP的多维关联数组中?
这里就是我试图做一个高层次的看法:
//While there are more records:
while ($row = mysql_fetch_assoc($result)) {
//If this key doeesn't already exist in the return array,
//add this key/value pair.
//Proper logic for determining whether or not a cell has already been
//created for this record would go here...
$ret[$row['output_row_id']][$row['output_name']] = $row['output_value'];
}
预先感谢您所有的帮助,所以!
这完美地工作。我正在查看array_key_exists的文档,它似乎不支持多维键。谢谢! – 2009-10-14 20:56:57