I have this section of PHP code, which takes the response from an API and then checks to see if a particular part of the response matches a variable.
Like below... in the array attribution is there a source_id that matches $this_id?
$this_id = 15;
$array = json_decode($response, true);
if (in_array($this_id, array_column($array['data']['attribution'], 'source_id'))) {
// then do this
}
else {
// then do this instead
}
This works perfectly. What I'm trying to do is get some additional data from this array without having to call the API all over again. The logic would be as above, but then if true return the value for ['data']['attribution']['item_number']. Keeping in mind that there might be a bunch of objects in the attribution.
How can I return this value?
['item_number']in the call to API?