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]=> string(3) "160" [165]=> string(3) "165" [170]=> string(3) "170" [172]=> string(3) "172" [174]=> string(3) "174" [176]=> string(3) "176" [178]=> string(3) "178" [180]=> string(3) "180" [182]=> string(3) "182" [184]=> string(3) "184" [186]=> string(3) "186" [188]=> string(3) "188" [190]=> string(3) "190" [195]=> string(3) "195" [200]=> &string(3) "200" } Warning: array_map(): Expected parameter 2 to be an array, string given in /in/DPdJR on line 35 Warning: array_combine() expects parameter 1 to be array, string given in /in/DPdJR on line 36 Fatal error: Uncaught Error: Unsupported operand types in /in/DPdJR:38 Stack trace: #0 {main} thrown in /in/DPdJR on line 38
Process exited with code 255.