Hello,
I am struggling with successfully have a function call itself to populate an array with unique values.
The code works without the recursions but I will include the entire code body for the function here here as it is fairly small.
I have changed the url values to pseudo server and url however.
So what i need to do is to fully populate the array name $iarray() so this is a global scope value.
Also the variable $passes which is changed based on recursion level and $passesallowed which is set only once and passed down.
The one other stipulation is that I need to stop the recursion at a specified level or passes say counting levels down to 3 or 4 deep.
I look to populate the $iarray with an $id value. The $ascend value is used to determine last positions
and if the $ascend number is greater than 255 the recursion occurs ($ascend can go up to a value of 512).
Here is my coding and I do appreciate any help with this. Perhaps my folly is not having this as a class?
Any way here is my code
<?php
session_start();
include ("mycurl.php");
extract($_POST);
$server = "https://mystuff.com";
$iarray = array();
$passcnt = 0;
function get_ids($server, $id, &$passcnt, $passesallowed, &$iarray) {
if ($passcnt <= $passesallowed) {
$httpurl = $server."/get_levels/getinfo=8";
$jsondata=http($httpurl, $_SESSION['token']);
$json_a=json_decode($jsondata,true);
foreach($json_a['persons'] as $p) {
$mid = $p['id'];
if (strlen($mid) == 8) {
$ascend = $p['display']['ascendancyNumber'];
if (!in_array($mid, $iarray)) {
array_push($iarray, $mid);
if ($ascend > 255) {
if ($passcnt == 0) { $passcnt += 1; }
get_ids($server, $mid, $passcnt, $passesallowed, $iarray)
}
}
}
}
}
}
get_ids($server, $id, $passcnt, ceil($_SESSION['deep']/9), $iarray)
/?>
Thank you very much for any help in getting this to process properly.
Kim