I am having a problem with a php function, it is a recursive function - which seems to work, because if i dump the array I see the items are added to the array. But when I want to return the array I get a null
.
The api function is a http curl
wrapper function which handles the api call - that works fine, also the $arr
get's filled with the db_address
items - but the return doesn't return the array - if I var_dump
the result I get a Null
, if I print_r
the result I just get a 1
.
function get_all_db_addresses($arr, $skip){
if(!isset($arr)){
$arr = [];
}
if(!isset($skip)){
$skip = 0;
}
$db_addresses = json_decode(db_api('GET', 'DbAddress?$skip=' . $skip), true);
$arr = array_merge($arr, $db_addresses['value']);
if(!array_key_exists('@odata.nextLink', $db_addresses)){
return $arr;
} else {
$skip += 20;
get_all_db_addresses($arr, $skip);
}
}
Am i doing something wrong here? I don't see what i'm doing wrong here..