如何推动数组内的“邻接”键值对应该有一个封装数组保持“数组”(即数组(“”节点“=>”$到“),(”nodeTo“=>”$ to“))),而不会覆盖它们并将它们附加到”+ =“类似的位置。推动关键“邻接关系”似乎也没有提升价值。推动和相关数组到php中的关联数组
$node[] = array(
"adjacencies" => array(), //inside this array should go all the arrays seprated by commas.
"data" => array(
"color" => $color1,
"type" => $type1
);
// this push doesnt seem to detect the adjacencies value and doesnt really push the array inside of the container array. I also tried $node["adjacencies"][]=array("nodeTo" => "$to"); but it didnt work
$node["adjacencies"]=array("nodeTo" => "$to");
}
这里的'0'是什么? – zerkms
'$ node [] = array(...)'意味着当一个数组被添加到'$ node'时,$ node [0]存在。 – Aiias
是的,但事情是 - OP不想将它添加到第0个元素 – zerkms