I have rewritten some of the function and it appears that the issue I really need to
remedy is why it appears a new array is created for $iarray and $donearray each time
the function is called instead of just using the arrays passed in be reference?
Can anyone help in resolving this issue. See code below.
Thanks,
Kim H.
function get4gen($server, $id, &$iarray, &$donearray) {
static $cnt;
$httpurl = $server."/platform/tree/ancestry?person=".$id;
echo $httpurl."<br>";
$xmldata=http($httpurl);
$json_a=json_decode($xmldata,true);
foreach($json_a[persons] as $p)
{
$id = $p[id];
echo "ID: ".$id."<br>";
if (strlen($id) == 8) {
$ascend = $p[display][ascendancyNumber];
$avals = "$id,$ascend";
if ($ascend == 1) { $cnt++; }
if ($cnt > 576) { break; }
if (!in_array($id, $donearray)) {
array_push($iarray, $avals);
array_push($donearray, $id);
}
}
}
echo "IARRAY HERE>>>>>><br>";
var_dump($iarray);
echo "<br><br>DONEARRAY HERE>>>>>><br>";
var_dump($donearray);
echo "<br><br>";
foreach($iarray as $pair) {
$arr = explode(",",$pair);
echo "ID2: ".$arr[0].", ".$arr[1]."<br>";
if (($arr[1] > 7) && !in_array($arr[0], $donearray)) {
get4gen($server, $arr[0], $iarray, $donearray);
}
}
}