3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = [ ['2', 163], ['5', 9] ]; $from = 1; $till = 18; $days = array_column($array, 0); $result = array_map(function($day) use ($array, $days) { return (false!==$key=array_search($day, $days))? $array[$key]: [$day, 0]; },range($from, $till)); var_dump($result);
Output for 5.5.0 - 7.1.0
array(18) { [0]=> array(2) { [0]=> int(1) [1]=> int(0) } [1]=> array(2) { [0]=> string(1) "2" [1]=> int(163) } [2]=> array(2) { [0]=> int(3) [1]=> int(0) } [3]=> array(2) { [0]=> int(4) [1]=> int(0) } [4]=> array(2) { [0]=> string(1) "5" [1]=> int(9) } [5]=> array(2) { [0]=> int(6) [1]=> int(0) } [6]=> array(2) { [0]=> int(7) [1]=> int(0) } [7]=> array(2) { [0]=> int(8) [1]=> int(0) } [8]=> array(2) { [0]=> int(9) [1]=> int(0) } [9]=> array(2) { [0]=> int(10) [1]=> int(0) } [10]=> array(2) { [0]=> int(11) [1]=> int(0) } [11]=> array(2) { [0]=> int(12) [1]=> int(0) } [12]=> array(2) { [0]=> int(13) [1]=> int(0) } [13]=> array(2) { [0]=> int(14) [1]=> int(0) } [14]=> array(2) { [0]=> int(15) [1]=> int(0) } [15]=> array(2) { [0]=> int(16) [1]=> int(0) } [16]=> array(2) { [0]=> int(17) [1]=> int(0) } [17]=> array(2) { [0]=> int(18) [1]=> int(0) } }
Output for 5.4.0 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/epdQ4 on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/epdQ4 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/epdQ4 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/epdQ4 on line 3
Process exited with code 255.