<?php
//I set up 2 arrays, the $idArray to use in the 2nd API call and $testNull
$idArray = array();
$testNull = array();
$results = [
['id'=>1],['id'=>2],['id'=>3],['id'=>4],
['id'=>5],['id'=>6],['id'=>1],['id'=>8],
['id'=>9],['id'=>10],['id'=>11],['id'=>12],
['id'=>13],['id'=>14],['id'=>15],['id'=>16],
['id'=>17],['id'=>18],['id'=>19],['id'=>20],
];
//the JSON response is decoded previously and here I go through the first 20 results
for($j = 0; $j < 20; $j++){
//Here I put the ID of each venue into $busID
$busID = $results[$j]['id'];
//In case the result is null I have set up this if statement
if(!empty($busID)){
//This is echoing out the IDs of the venues correctly
echo $busID;
//and here the problem lies - just can't get the IDs in $idArray
array_push($idArray, $busID);
}else{
//I set this up just to test NUll responses from the 1st API call.
array_push($testNull, $busID);
}
}
var_dump($idArray);
var_dump($testNull);