标签:style blog ar color 使用 sp div log bs
当在使用arry_push方法向数组中某个子元素中中添加元素时应该注意,如例若使用预定义好的元素push,则会出现以下情况:
这里 "children" => $nodeList 与 array_push($bladeList[0][‘children‘],$nodeList);得到的结果不同!
$bladeList = array(); $nodeList = array(); array_push($nodeList, array( "text" => ‘test’, "status" => ‘1’, "checked" => false, "leaf" => true )); array_push($bladeList, array( "text" =>‘testrt’, "status" => ‘1’, "expanded" => true, "checked" => false, "children" => $nodeList )); array_push($bladeList[0][‘children‘],$nodeList);
输出结果如下:
0: checked: false children: 0: checked: false expanded: true text: "3"
children:
//"children" => $nodeList 得到以下结构
0: checked: false leaf: true status: 0 text: "108"
//array_push($bladeList[0][‘children‘],$nodeList); 得到以下结构
1: 0: checked: false leaf: true status: 0 text: "108"
expanded: true
text: "10.0"
array_push($bladeList[0][‘children‘],$nodeList);
标签:style blog ar color 使用 sp div log bs
原文地址:http://www.cnblogs.com/goddyk/p/4121054.html