3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getLinks() : array { if (rand(1,4) === 1) return ['a', 'b', 'c']; return []; } $links = []; foreach (range(1,7) as $a) { $links = getLinks(); if (count($links)) break; } print implode("\n", $links);
Output for 7.0.0, 7.0.2 - 7.0.13, 7.0.15 - 7.0.30, 7.0.32 - 7.0.33, 7.1.0 - 7.1.16, 7.1.18 - 7.1.33, 7.2.0 - 7.2.8, 7.2.10 - 7.2.24, 7.2.26, 7.3.0 - 7.3.10, 7.3.12 - 7.3.13, 7.4.1
a b c
Output for 7.0.1, 7.0.14, 7.0.31, 7.1.17, 7.2.9, 7.2.25, 7.3.11, 7.4.0
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting '{' in /in/IArR3 on line 3
Process exited with code 255.

preferences:
125.46 ms | 401 KiB | 157 Q