3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $master = array(); $arrColors = array('R', 'B', 'G' ,'Y'); $arrNumbers = array('1', '2', '3', '4'); foreach($arrColors as $color) { foreach($arrNumbers as $num) { $arr2 = array_push($master, $num); //$master += array($color => $num); //echo $color.' => '.$num; //echo "\n"; } array_push($arr2, $color); } print_r($master);
based on Vd3iu
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: array_push() expects parameter 1 to be array, integer given in /in/CuWeK on line 13 Warning: array_push() expects parameter 1 to be array, integer given in /in/CuWeK on line 13 Warning: array_push() expects parameter 1 to be array, integer given in /in/CuWeK on line 13 Warning: array_push() expects parameter 1 to be array, integer given in /in/CuWeK on line 13 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 1 [5] => 2 [6] => 3 [7] => 4 [8] => 1 [9] => 2 [10] => 3 [11] => 4 [12] => 1 [13] => 2 [14] => 3 [15] => 4 )
Output for hhvm-3.12.0
Warning: Invalid operand type was used: array_push expects array(s) or collection(s) in /in/CuWeK on line 13 Warning: Invalid operand type was used: array_push expects array(s) or collection(s) in /in/CuWeK on line 13 Warning: Invalid operand type was used: array_push expects array(s) or collection(s) in /in/CuWeK on line 13 Warning: Invalid operand type was used: array_push expects array(s) or collection(s) in /in/CuWeK on line 13 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 1 [5] => 2 [6] => 3 [7] => 4 [8] => 1 [9] => 2 [10] => 3 [11] => 4 [12] => 1 [13] => 2 [14] => 3 [15] => 4 )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.2 - 5.2.17
Warning: array_push(): First argument should be an array in /in/CuWeK on line 13 Warning: array_push(): First argument should be an array in /in/CuWeK on line 13 Warning: array_push(): First argument should be an array in /in/CuWeK on line 13 Warning: array_push(): First argument should be an array in /in/CuWeK on line 13 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 1 [5] => 2 [6] => 3 [7] => 4 [8] => 1 [9] => 2 [10] => 3 [11] => 4 [12] => 1 [13] => 2 [14] => 3 [15] => 4 )
Output for 4.3.0 - 4.3.1
Warning: array_push() [http://www.php.net/function.array-push]: First argument should be an array in /in/CuWeK on line 13 Warning: array_push() [http://www.php.net/function.array-push]: First argument should be an array in /in/CuWeK on line 13 Warning: array_push() [http://www.php.net/function.array-push]: First argument should be an array in /in/CuWeK on line 13 Warning: array_push() [http://www.php.net/function.array-push]: First argument should be an array in /in/CuWeK on line 13 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 1 [5] => 2 [6] => 3 [7] => 4 [8] => 1 [9] => 2 [10] => 3 [11] => 4 [12] => 1 [13] => 2 [14] => 3 [15] => 4 )