I am trying to write a function that retrieves specific data via cURL. The problem I am running into is that I want the data retrieved to be resolved within the function itself and then returned, rather than obtaining the curl response via the function and THEN retrieving the data outside of the function.
It's somewhat difficult to explain, however to put it simply, here is essentially what I have been doing up until now:
$response = getData(); // pretend this retrieves a bunch of decoded JSON data from a website via cURL
$data[] = $response->july->value; // this data is retrieved outside of the getData function
$data[] = $response->info->folders->data->key
But what I'd like to do is something like this:
$data = getData([
"[RESPONSE]->july->value",
"[RESPONSE]->info->folders->data->key"
]);
Where [RESPONSE] in the two strings would get replaced with the cURL response within the getData function and just return me the results I want (as $data[0] and $data[1], or however many arguments I pass to the function).
The problem with this is that once I turn the two example arguments above into strings, they are no longer objects - Is there a way to build them back up within the function and retrieve the data I want?