3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function P(array $sources) { $result=array(); $cache=array(); foreach($sources as $node) { $cache=$result; $result=array(); foreach($node as $item) { if(empty($cache)) { $result[]=array($item); } else { foreach($cache as $line) { $line[]=$item; $result[]=$line; } } } } return $result; } $result=P(array( array('Retail', 'Wholesale'), array('NORTH ZONE', 'WEST ZONE','EAST ZONE','NORTH-EAST ZONE','SOUTH ZONE'), array('Rice', 'Wheat','Atta (Wheat)','Gram Dal','Tur/Arhar Dal','Urad Dal','Moong Dal','Masoor Dal','Sugar','Milk @','Groundnut Oil (Packed)','Mustard Oil (Packed)','Vanaspati (Packed)','Soya Oil (Packed)','Sunflower Oil (Packed)','Sunflower Oil (Packed)','Palm Oil (Packed)','Gur','Tea Loose','Salt Pack (Iodised)','Potato','Onion','Tomato'))); print_r(array_map(function($a){return implode(",",$a);},$result));
Output for 5.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Retail,NORTH ZONE,Rice [1] => Wholesale,NORTH ZONE,Rice [2] => Retail,WEST ZONE,Rice [3] => Wholesale,WEST ZONE,Rice [4] => Retail,EAST ZONE,Rice [5] => Wholesale,EAST ZONE,Rice [6] => Retail,NORTH-EAST ZONE,Rice [7] => Wholesale,NORTH-EAST ZONE,Rice [8] => Retail,SOUTH ZONE,Rice [9] => Wholesale,SOUTH ZONE,Rice [10] => Retail,NORTH ZONE,Wheat [11] => Wholesale,NORTH ZONE,Wheat [12] => Retail,WEST ZONE,Wheat [13] => Wholesale,WEST ZONE,Wheat [14] => Retail,EAST ZONE,Wheat [15] => Wholesale,EAST ZONE,Wheat [16] => Retail,NORTH-EAST ZONE,Wheat [17] => Wholesale,NORTH-EAST ZONE,Wheat [18] => Retail,SOUTH ZONE,Wheat [19] => Wholesale,SOUTH ZONE,Wheat [20] => Retail,NORTH ZONE,Atta (Wheat) [21] => Wholesale,NORTH ZONE,Atta (Wheat) [22] => Retail,WEST ZONE,Atta (Wheat) [23] => Wholesale,WEST ZONE,Atta (Wheat) [24] => Retail,EAST ZONE,Atta (Wheat) [25] => Wholesale,EAST ZONE,Atta (Wheat) [26] => Retail,NORTH-EAST ZONE,Atta (Wheat) [27] => Wholesale,NORTH-EAST ZONE,Atta (Wheat) [28] => Retail,SOUTH ZONE,Atta (Wheat) [29] => Wholesale,SOUTH ZONE,Atta (Wheat) [30] => Retail,NORTH ZONE,Gram Dal [31] => Wholesale,NORTH ZONE,Gram Dal [32] => Retail,WEST ZONE,Gram Dal [33] => Wholesale,WEST ZONE,Gram Dal [34] => Retail,EAST ZONE,Gram Dal [35] => Wholesale,EAST ZONE,Gram Dal [36] => Retail,NORTH-EAST ZONE,Gram Dal [37] => Wholesale,NORTH-EAST ZONE,Gram Dal [38] => Retail,SOUTH ZONE,Gram Dal [39] => Wholesale,SOUTH ZONE,Gram Dal [40] => Retail,NORTH ZONE,Tur/Arhar Dal [41] => Wholesale,NORTH ZONE,Tur/Arhar Dal [42] => Retail,WEST ZONE,Tur/Arhar Dal [43] => Wholesale,WEST ZONE,Tur/Arhar Dal [44] => Retail,EAST ZONE,Tur/Arhar Dal [45] => Wholesale,EAST ZONE,Tur/Arhar Dal [46] => Retail,NORTH-EAST ZONE,Tur/Arhar Dal [47] => Wholesale,NORTH-EAST ZONE,Tur/Arhar Dal [48] => Retail,SOUTH ZONE,Tur/Arhar Dal [49] => Wholesale,SOUTH ZONE,Tur/Arhar Dal [50] => Retail,NORTH ZONE,Urad Dal [51] => Wholesale,NORTH ZONE,Urad Dal [52] => Retail,WEST ZONE,Urad Dal [53] => Wholesale,WEST ZONE,Urad Dal [54] => Retail,EAST ZONE,Urad Dal [55] => Wholesale,EAST ZONE,Urad Dal [56] => Retail,NORTH-EAST ZONE,Urad Dal [57] => Wholesale,NORTH-EAST ZONE,Urad Dal [58] => Retail,SOUTH ZONE,Urad Dal [59] => Wholesale,SOUTH ZONE,Urad Dal [60] => Retail,NORTH ZONE,Moong Dal [61] => Wholesale,NORTH ZONE,Moong Dal [62] => Retail,WEST ZONE,Moong Dal [63] => Wholesale,WEST ZONE,Moong Dal [64] => Retail,EAST ZONE,Moong Dal [65] => Wholesale,EAST ZONE,Moong Dal [66] => Retail,NORTH-EAST ZONE,Moong Dal [67] => Wholesale,NORTH-EAST ZONE,Moong Dal [68] => Retail,SOUTH ZONE,Moong Dal [69] => Wholesale,SOUTH ZONE,Moong Dal [70] => Retail,NORTH ZONE,Masoor Dal [71] => Wholesale,NORTH ZONE,Masoor Dal [72] => Retail,WEST ZONE,Masoor Dal [73] => Wholesale,WEST ZONE,Masoor Dal [74] => Retail,EAST ZONE,Masoor Dal [75] => Wholesale,EAST ZONE,Masoor Dal [76] => Retail,NORTH-EAST ZONE,Masoor Dal [77] => Wholesale,NORTH-EAST ZONE,Masoor Dal [78] => Retail,SOUTH ZONE,Masoor Dal [79] => Wholesale,SOUTH ZONE,Masoor Dal [80] => Retail,NORTH ZONE,Sugar [81] => Wholesale,NORTH ZONE,Sugar [82] => Retail,WEST ZONE,Sugar [83] => Wholesale,WEST ZONE,Sugar [84] => Retail,EAST ZONE,Sugar [85] => Wholesale,EAST ZONE,Sugar [86] => Retail,NORTH-EAST ZONE,Sugar [87] => Wholesale,NORTH-EAST ZONE,Sugar [88] => Retail,SOUTH ZONE,Sugar [89] => Wholesale,SOUTH ZONE,Sugar [90] => Retail,NORTH ZONE,Milk @ [91] => Wholesale,NORTH ZONE,Milk @ [92] => Retail,WEST ZONE,Milk @ [93] => Wholesale,WEST ZONE,Milk @ [94] => Retail,EAST ZONE,Milk @ [95] => Wholesale,EAST ZONE,Milk @ [96] => Retail,NORTH-EAST ZONE,Milk @ [97] => Wholesale,NORTH-EAST ZONE,Milk @ [98] => Retail,SOUTH ZONE,Milk @ [99] => Wholesale,SOUTH ZONE,Milk @ [100] => Retail,NORTH ZONE,Groundnut Oil (Packed) [101] => Wholesale,NORTH ZONE,Groundnut Oil (Packed) [102] => Retail,WEST ZONE,Groundnut Oil (Packed) [103] => Wholesale,WEST ZONE,Groundnut Oil (Packed) [104] => Retail,EAST ZONE,Groundnut Oil (Packed) [105] => Wholesale,EAST ZONE,Groundnut Oil (Packed) [106] => Retail,NORTH-EAST ZONE,Groundnut Oil (Packed) [107] => Wholesale,NORTH-EAST ZONE,Groundnut Oil (Packed) [108] => Retail,SOUTH ZONE,Groundnut Oil (Packed) [109] => Wholesale,SOUTH ZONE,Groundnut Oil (Packed) [110] => Retail,NORTH ZONE,Mustard Oil (Packed) [111] => Wholesale,NORTH ZONE,Mustard Oil (Packed) [112] => Retail,WEST ZONE,Mustard Oil (Packed) [113] => Wholesale,WEST ZONE,Mustard Oil (Packed) [114] => Retail,EAST ZONE,Mustard Oil (Packed) [115] => Wholesale,EAST ZONE,Mustard Oil (Packed) [116] => Retail,NORTH-EAST ZONE,Mustard Oil (Packed) [117] => Wholesale,NORTH-EAST ZONE,Mustard Oil (Packed) [118] => Retail,SOUTH ZONE,Mustard Oil (Packed) [119] => Wholesale,SOUTH ZONE,Mustard Oil (Packed) [120] => Retail,NORTH ZONE,Vanaspati (Packed) [121] => Wholesale,NORTH ZONE,Vanaspati (Packed) [122] => Retail,WEST ZONE,Vanaspati (Packed) [123] => Wholesale,WEST ZONE,Vanaspati (Packed) [124] => Retail,EAST ZONE,Vanaspati (Packed) [125] => Wholesale,EAST ZONE,Vanaspati (Packed) [126] => Retail,NORTH-EAST ZONE,Vanaspati (Packed) [127] => Wholesale,NORTH-EAST ZONE,Vanaspati (Packed) [128] => Retail,SOUTH ZONE,Vanaspati (Packed) [129] => Wholesale,SOUTH ZONE,Vanaspati (Packed) [130] => Retail,NORTH ZONE,Soya Oil (Packed) [131] => Wholesale,NORTH ZONE,Soya Oil (Packed) [132] => Retail,WEST ZONE,Soya Oil (Packed) [133] => Wholesale,WEST ZONE,Soya Oil (Packed) [134] => Retail,EAST ZONE,Soya Oil (Packed) [135] => Wholesale,EAST ZONE,Soya Oil (Packed) [136] => Retail,NORTH-EAST ZONE,Soya Oil (Packed) [137] => Wholesale,NORTH-EAST ZONE,Soya Oil (Packed) [138] => Retail,SOUTH ZONE,Soya Oil (Packed) [139] => Wholesale,SOUTH ZONE,Soya Oil (Packed) [140] => Retail,NORTH ZONE,Sunflower Oil (Packed) [141] => Wholesale,NORTH ZONE,Sunflower Oil (Packed) [142] => Retail,WEST ZONE,Sunflower Oil (Packed) [143] => Wholesale,WEST ZONE,Sunflower Oil (Packed) [144] => Retail,EAST ZONE,Sunflower Oil (Packed) [145] => Wholesale,EAST ZONE,Sunflower Oil (Packed) [146] => Retail,NORTH-EAST ZONE,Sunflower Oil (Packed) [147] => Wholesale,NORTH-EAST ZONE,Sunflower Oil (Packed) [148] => Retail,SOUTH ZONE,Sunflower Oil (Packed) [149] => Wholesale,SOUTH ZONE,Sunflower Oil (Packed) [150] => Retail,NORTH ZONE,Sunflower Oil (Packed) [151] => Wholesale,NORTH ZONE,Sunflower Oil (Packed) [152] => Retail,WEST ZONE,Sunflower Oil (Packed) [153] => Wholesale,WEST ZONE,Sunflower Oil (Packed) [154] => Retail,EAST ZONE,Sunflower Oil (Packed) [155] => Wholesale,EAST ZONE,Sunflower Oil (Packed) [156] => Retail,NORTH-EAST ZONE,Sunflower Oil (Packed) [157] => Wholesale,NORTH-EAST ZONE,Sunflower Oil (Packed) [158] => Retail,SOUTH ZONE,Sunflower Oil (Packed) [159] => Wholesale,SOUTH ZONE,Sunflower Oil (Packed) [160] => Retail,NORTH ZONE,Palm Oil (Packed) [161] => Wholesale,NORTH ZONE,Palm Oil (Packed) [162] => Retail,WEST ZONE,Palm Oil (Packed) [163] => Wholesale,WEST ZONE,Palm Oil (Packed) [164] => Retail,EAST ZONE,Palm Oil (Packed) [165] => Wholesale,EAST ZONE,Palm Oil (Packed) [166] => Retail,NORTH-EAST ZONE,Palm Oil (Packed) [167] => Wholesale,NORTH-EAST ZONE,Palm Oil (Packed) [168] => Retail,SOUTH ZONE,Palm Oil (Packed) [169] => Wholesale,SOUTH ZONE,Palm Oil (Packed) [170] => Retail,NORTH ZONE,Gur [171] => Wholesale,NORTH ZONE,Gur [172] => Retail,WEST ZONE,Gur [173] => Wholesale,WEST ZONE,Gur [174] => Retail,EAST ZONE,Gur [175] => Wholesale,EAST ZONE,Gur [176] => Retail,NORTH-EAST ZONE,Gur [177] => Wholesale,NORTH-EAST ZONE,Gur [178] => Retail,SOUTH ZONE,Gur [179] => Wholesale,SOUTH ZONE,Gur [180] => Retail,NORTH ZONE,Tea Loose [181] => Wholesale,NORTH ZONE,Tea Loose [182] => Retail,WEST ZONE,Tea Loose [183] => Wholesale,WEST ZONE,Tea Loose [184] => Retail,EAST ZONE,Tea Loose [185] => Wholesale,EAST ZONE,Tea Loose [186] => Retail,NORTH-EAST ZONE,Tea Loose [187] => Wholesale,NORTH-EAST ZONE,Tea Loose [188] => Retail,SOUTH ZONE,Tea Loose [189] => Wholesale,SOUTH ZONE,Tea Loose [190] => Retail,NORTH ZONE,Salt Pack (Iodised) [191] => Wholesale,NORTH ZONE,Salt Pack (Iodised) [192] => Retail,WEST ZONE,Salt Pack (Iodised) [193] => Wholesale,WEST ZONE,Salt Pack (Iodised) [194] => Retail,EAST ZONE,Salt Pack (Iodised) [195] => Wholesale,EAST ZONE,Salt Pack (Iodised) [196] => Retail,NORTH-EAST ZONE,Salt Pack (Iodised) [197] => Wholesale,NORTH-EAST ZONE,Salt Pack (Iodised) [198] => Retail,SOUTH ZONE,Salt Pack (Iodised) [199] => Wholesale,SOUTH ZONE,Salt Pack (Iodised) [200] => Retail,NORTH ZONE,Potato [201] => Wholesale,NORTH ZONE,Potato [202] => Retail,WEST ZONE,Potato [203] => Wholesale,WEST ZONE,Potato [204] => Retail,EAST ZONE,Potato [205] => Wholesale,EAST ZONE,Potato [206] => Retail,NORTH-EAST ZONE,Potato [207] => Wholesale,NORTH-EAST ZONE,Potato [208] => Retail,SOUTH ZONE,Potato [209] => Wholesale,SOUTH ZONE,Potato [210] => Retail,NORTH ZONE,Onion [211] => Wholesale,NORTH ZONE,Onion [212] => Retail,WEST ZONE,Onion [213] => Wholesale,WEST ZONE,Onion [214] => Retail,EAST ZONE,Onion [215] => Wholesale,EAST ZONE,Onion [216] => Retail,NORTH-EAST ZONE,Onion [217] => Wholesale,NORTH-EAST ZONE,Onion [218] => Retail,SOUTH ZONE,Onion [219] => Wholesale,SOUTH ZONE,Onion [220] => Retail,NORTH ZONE,Tomato [221] => Wholesale,NORTH ZONE,Tomato [222] => Retail,WEST ZONE,Tomato [223] => Wholesale,WEST ZONE,Tomato [224] => Retail,EAST ZONE,Tomato [225] => Wholesale,EAST ZONE,Tomato [226] => Retail,NORTH-EAST ZONE,Tomato [227] => Wholesale,NORTH-EAST ZONE,Tomato [228] => Retail,SOUTH ZONE,Tomato [229] => Wholesale,SOUTH ZONE,Tomato )
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/IPP7s on line 29
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/IPP7s on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/IPP7s on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/IPP7s on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/IPP7s on line 2
Process exited with code 255.