3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function decartProduct($one, $two) { $result = []; for($i=0; $i<count($one); $i++) { for($j=0; $j<count($two); $j++) { if(1) { $result[]=array_merge((array)$one[$i], (array)$two[$j]); } } } return $result; } function createAssociation() { $args = func_get_args(); if(!count($args)) { return []; } $result = array_shift($args); while($array=array_shift($args)) { $result=decartProduct($result, $array); } return $result; } $i[0] = ['a', 'b', 'c']; $i[1] = ['d', 'e']; $i[2] = ['a', 'b', 'c']; $i[3] = ['d', 'e']; $i[4] = ['f', 'g', 'h']; $result = call_user_func_array('createAssociation', $i); var_dump($result);
Output for 5.4.0 - 5.6.21, hhvm-3.12.0, 7.0.0 - 7.1.0
array(108) { [0]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [1]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [2]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [3]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [4]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [5]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [6]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [7]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [8]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [9]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [10]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [11]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [12]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [13]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [14]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [15]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [16]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [17]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } [18]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [19]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [20]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [21]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [22]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [23]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [24]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [25]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [26]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [27]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [28]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [29]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [30]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [31]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [32]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [33]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [34]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [35]=> array(5) { [0]=> string(1) "a" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } [36]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [37]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [38]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [39]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [40]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [41]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [42]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [43]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [44]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [45]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [46]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [47]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [48]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [49]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [50]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [51]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [52]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [53]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } [54]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [55]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [56]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [57]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [58]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [59]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [60]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [61]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [62]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [63]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [64]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [65]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [66]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [67]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [68]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [69]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [70]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [71]=> array(5) { [0]=> string(1) "b" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } [72]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [73]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [74]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [75]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [76]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [77]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [78]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [79]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [80]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [81]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [82]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [83]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [84]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [85]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [86]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [87]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [88]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [89]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "d" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } [90]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "f" } [91]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "g" } [92]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "d" [4]=> string(1) "h" } [93]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "f" } [94]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "g" } [95]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "a" [3]=> string(1) "e" [4]=> string(1) "h" } [96]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "f" } [97]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "g" } [98]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "d" [4]=> string(1) "h" } [99]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "f" } [100]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "g" } [101]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "h" } [102]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "f" } [103]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "g" } [104]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "h" } [105]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "f" } [106]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "g" } [107]=> array(5) { [0]=> string(1) "c" [1]=> string(1) "e" [2]=> string(1) "c" [3]=> string(1) "e" [4]=> string(1) "h" } }
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/tNvp4 on line 4
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/tNvp4 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/tNvp4 on line 4
Process exited with code 255.