3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array( array('f1', 'f2', 'f3'), array('s1', 's2', 's3', 's4', 's5'), array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 't10', 't11', 't12') ); $max = 12; $each = $max / count($data); $result = array(); $missing = 0; foreach ($data as $set) { $missing += $each; while (count($set) > 0 && $missing > 0) { $result[] = array_shift($set); $missing--; } } print_r($result);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => f1 [1] => f2 [2] => f3 [3] => s1 [4] => s2 [5] => s3 [6] => s4 [7] => s5 [8] => t1 [9] => t2 [10] => t3 [11] => t4 )
Output for hhvm-3.10.0

Process exited with code 153.