如果有人可以解释,请注意以下内容:
$ref[$i] =& $ref[$p][$i]['ch'];
在以下代码中执行:
<?php
$retv = array();
array_push($retv, array('record-id' => 1, 'record-parent' => 0));
array_push($retv, array('record-id' => 2, 'record-parent' => 1));
array_push($retv, array('record-id' => 7, 'record-parent' => 0));
array_push($retv, array('record-id' => 8, 'record-parent' => 7));
array_push($retv, array('record-id' => 9, 'record-parent' => 8));
$ret = array('root'=>array());
$ref[0] =& $ret['root'];
foreach($retv as $row) {
$p=$row['record-parent'];
$i=$row['record-id'];
$ref[$p][$i] = array('data'=>$row,'ch'=>array());
$ref[$i] =& $ref[$p][$i]['ch'];
}
echo '<pre>'; print_r($ret); echo '</pre>';
?>
非常感谢。 沃伊切赫
答案 0 :(得分:1)