填充数组返回空白

I am retrieving data from an api using curl with php. I am able to successfully get a response from the api and retrieve the data i want from it. My problem arises whenever I try to pass the data into an array to be able to return it, as when I use var_dump() on the array it is empty. Any pointers on how to get this array to return its values would be great

// decode json string into array
$output = json_decode($output, true);

// check if the supplied data is an array
if(is_array($output)){
//loop through the first level of the array
foreach($output as $key => $value) {
   //assigning variable values

    $btcDominance = ["btc_dominance"];
   $errorMsg = $value["error_message"];
$errorCode = $value["error_code"];
$timestamp = $value["last_updated"];





//check if the next level is an array and loop through it
if(is_array($value)) {
foreach($value as $key => $values) {


//check if the next level is an array and loop through it
    if(is_array($values)) {
    foreach($values as $keys => $value3) {
    //check if the next level is an array and loop through it

        $marketCap = $value3["total_market_cap"];
        $volume = $value3["total_volume_24h"];





$values = array('btc' => $btcDominance,
'errMsg' => $errorMsg);
return $values;


}//foreach3

}//isarray 3        

}//foreach2

}//is array 2       

}//foreach1
}//is array 1



}//end of qryCmc

I think the getValues function might be the reason the array is returning as blank, but if i remove the " ='' " from this function I get an Warning: Missing argument 1 for Cmc::getValues(),

function getValues($values ='') {
return $this->output;
}
}// end of Cmc



  $cmc = new Cmc();
  var_dump($cmc->getValues());