3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php for ($x=1; $x<6; ++$x) { $unions[] = "SELECT " . ($x==1 ? "$x AS challenge_id, 1 as week_id" : "$x, 1"); $unions[] = "SELECT $x, 6"; } $derived_table = implode(' UNION ',$unions); ECHO $derived_table;
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
SELECT 1 AS challenge_id, 1 as week_id UNION SELECT 1, 6 UNION SELECT 2, 1 UNION SELECT 2, 6 UNION SELECT 3, 1 UNION SELECT 3, 6 UNION SELECT 4, 1 UNION SELECT 4, 6 UNION SELECT 5, 1 UNION SELECT 5, 6