$aliases = ""; for ($i = 0; $i < ($end = count($records)); $i++) { $aliases .= $records[$i]['alias']; $aliases .= $i + 1 < $end ? ", " : ""; } return $aliases; } else { return NULL; } } if (NULL != ($records = get_person($userid, $personid))) { if ($records[0]['birthday'] || $records[0]['imageBase64']) { put_info_for_person($records[0]); } if ($records[0]['got_phone']) { put_phones_for_person($records[0]['personid']); } if ($records[0]['got_address']) { put_addresses_for_person($records[0]['personid']); } if ($records[0]['comments']) { put_comments_for_person($records[0]['comments']); } //RELATIVES $array = array(); $stack = array(); front_flashback_relatives($array, $records[0], 0, $stack); //dump( $stack, "stack" ); } else { $_SESSION['error'] = "<b>ajax.php:</b><br />This contact does not exists!"; }
function front_flashback_relatives(&$array, $person, $cpl = 0, &$stack) { static $lpl = 0, $exception = 0; if (!in_array($exception, $stack)) { array_push($stack, $exception); } //For parents view only if ($cpl && NULL != $person) { $relation = get_relation_string($person['sex'], $cpl); echo "<p class='Debug2'>L:[0][" . $cpl . "]|ID:" . $person['personid'] . "|" . $relation . "|=> " . $person['name'] . " " . $person['surname'] . "</p>"; //dump( $stack, "stack" ); } else { $array = $person; } $array['other_children'] = array(); rear_flashback_relatives($person['personid'], $person['sex'], $cpl, 0, $person['number_of_childs'], $stack, $array['other_children']); $lpl = $cpl; $exception = $person['personid']; if ($person['motherid'] || $person['fatherid']) { $root = get_parrents($person['motherid'] ? $person['motherid'] : 0, $person['fatherid'] ? $person['fatherid'] : 0); $tmp = count($root); $array['motherid'] = $root[0]; $array['fatherid'] = $root[1]; ++$cpl; front_flashback_relatives($array['motherid'], $root[0], $cpl, $stack); //Αριστερό υποδένρο. //--$cpl; //++$cpl; front_flashback_relatives($array['fatherid'], $root[1], $cpl, $stack); //Δεξί υποδένρο. --$cpl; } }