我似乎可以让方法返回一个数组。我可以在
的myRecursiveFunction返回之前获取var_dumpif($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;
}
}
答案 0 :(得分:0)
只是必须这样做
return $this->myRecursiveFunction($result->getMore, true, $myArray);