【发布时间】:2009-10-14 20:34:43
【问题描述】:
为了简化这个提出的问题,假设每个单元格都有一个行名和一个列名,可以正确地将您映射到相应的单元格。我正在遍历数据库记录并为二维数组中的某些字段创建一个位置,我将返回给调用者。我的问题是如何判断 array[rownName][colName] 中是否已经存在一个单元格?
这是我正在尝试做的事情的高级视图:
//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'];
}
提前感谢您的所有帮助!
【问题讨论】:
标签: php multidimensional-array key