我创建了一个返回数组的脚本:
foreach ($ways as $w){
$nd=$w->nd;
foreach ($nd as $w2){
$nodes_Array[]=(string)$w2->attributes()->ref;
}
for($ww=0;$ww<count($nodes_Array);$ww++){
$nodes_Array2[$bb]['main'] = $nodes_Array[$ww];
$nodes_Array2[$bb]['conn'] = array_diff($nodes_Array, array($nodes_Array[$ww]));
for($cc=0;$cc<count($nodes_Array2[$bb]['conn']);$cc++){
for($gg=0;$gg<count($node_content);$gg++){
if($node_content[$gg]['id']==$nodes_Array2[$bb]['conn'][$cc]){
// MAYBE ADD SOME CODE HERE???
}
}
}
$bb++;
}
unset($nodes_Array);
}
输出数组:
[0] => Array
(
[main] => 472321514
[conn] => Array
(
[1] => 599416249
[2] => 2352406409
[3] => 496968074)
) ...
我正在尝试使用“键”(主键中的 id 和 conn 中的 lat,lon )添加“子数组”,并使该数组看起来像这样
[0] => Array
(
[main] => 472321514=>Array(
[id]=>.....
)
[conn] => Array
(
[1] => 599416249=>Array(
[lat]=>.....
[lon]=>....)
[2] => 2352406409=>Array(
[lat]=>.....
[lon]=>....)
)
有什么帮助吗??