@ 2015-09-10T16:03:03Z <?php
function sum() {
$list = array();
$prepare = function($value) use(&$prepare, &$list) {
if (is_array($value)) {
return $prepare(array_merge($list, $value));//array_map($prepare, );
}
$list[] = $value;
};
$args = func_get_args();
array_walk($args, $prepare, $list);
var_dump($list);
return addition(0, $list);
}
function addition($sum, array &$list) {
return empty($list) ? $sum : addition($sum + array_pop($list), $list);
}
$vars = range(1, 10);
echo sum(array($vars), array(1));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.13 , 7.4.0 - 7.4.1 , 8.1.28 , 8.2.18 , 8.3.5 - 8.3.6 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/nBHkF on line 7
Process exited with code 255 . Output for 8.2.15 - 8.2.17 , 8.3.2 - 8.3.4 Fatal error: Out of memory (allocated 31457280 bytes) (tried to allocate 262144 bytes) in /in/nBHkF on line 7
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
Process exited with code 255 . Output for 7.0.14 - 7.0.18 , 7.0.20 - 7.0.30 , 7.0.32 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.3 , 7.2.6 , 7.2.8 - 7.2.26 , 7.3.0 - 7.3.13 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/nBHkF on line 7
Process exited with code 255 . Output for 7.0.19 , 7.0.31 , 7.2.4 - 7.2.5 , 7.2.7 Process exited with code 137 . Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /in/nBHkF on line 7
Process exited with code 255 . preferences:dark mode live preview
192.42 ms | 402 KiB | 252 Q