我似乎可以让该方法返回一个数组。我可以在 myRecursiveFunction 返回之前获得 var_dump
if($return){
var_dump($myArray);
return $myArray;
}
但是在调用函数中我的 var_dump 是空的....不知道我做错了什么
private function myCallingFunction(){
$x = $this->myRecursiveFunction();
var_dump($x);
}
private function myRecursiveFunction($next = null, $recursion = false, $myArray = array())
{
$return = false;
if (!$recursion) {
$result = json_decode($this->getMyResults);
$myArray = $result->myResults;
if ($result->getMore) {
$this->myRecursiveFunction($result->getMore, true, $myArray);
$return = false;
}else{
$return = true;
}
} else {
$result = json_decode($this->getMyResults);
$myArray = array_merge($myArray,$result->myResults);
if ($result->getMore) {
$this->myRecursiveFunction($result->getMore, true, $myArray);
$return = false;
}else{
$return = true;
}
}
if($return){
var_dump($myArray);
return $myArray;
}
}