3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for git.master, git.master_jit, rfc.property-hooks
1234561891011121314151617181920array(20) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(1) [7]=> int(8) [8]=> int(9) [9]=> int(10) [10]=> int(11) [11]=> int(12) [12]=> int(13) [13]=> int(14) [14]=> int(15) [15]=> int(16) [16]=> int(17) [17]=> int(18) [18]=> int(19) [19]=> int(20) } array(0) { }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.09 ms | 402 KiB | 8 Q