3v4l.org

run code in 300+ PHP versions simultaneously
<?php function callApi($offset, $limit) { static $array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; echo "called with $offset, $limit\n"; return json_encode([ 'results' => array_slice($array, $offset, $limit), 'next' => array_key_last($array) >= $offset + $limit ]); } $offset = 0; $limit = 5; $result = []; do { $response = json_decode(callApi($offset, $limit), true); array_push($result, ...$response['results']); $offset += $limit; } while (!empty($response['next'])); var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
called with 0, 5 called with 5, 5 called with 10, 5 array ( 0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => 7, 7 => 8, 8 => 9, 9 => 10, 10 => 11, 11 => 12, )

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:
46.46 ms | 1007 KiB | 4 Q