3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $sizes = [ 200, 195, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 165, 160, ]; sort($sizes); $sizes = array_combine($sizes, $sizes); $keyRange = []; foreach($sizes as $key => &$size) { if (isset($sizes[$key+1])) { $sizes[$key] = range($size, $sizes[$key+1]-1); } } var_dump($sizes); $misterKeysRange = $sizes; $misterKeys = []; foreach($misterKeysRange as $value => $keys) { $values = array_map(function() use ($value){ return $value; }, $keys); $arr = array_combine($keys, $values); //var_dump($arr); $misterKeys = $misterKeys+$arr; } var_dump($misterKeys);
Output for 7.3.0rc3
array(15) { [160]=> int(160) [165]=> int(165) [170]=> int(170) [172]=> int(172) [174]=> int(174) [176]=> int(176) [178]=> int(178) [180]=> int(180) [182]=> int(182) [184]=> int(184) [186]=> int(186) [188]=> int(188) [190]=> int(190) [195]=> int(195) [200]=> &int(200) } Warning: array_map(): Expected parameter 2 to be an array, int given in /in/DmIQm on line 35 Warning: array_combine() expects parameter 1 to be array, int given in /in/DmIQm on line 36 Fatal error: Uncaught Error: Unsupported operand types in /in/DmIQm:38 Stack trace: #0 {main} thrown in /in/DmIQm on line 38
Process exited with code 255.