3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function add() { $list = array(); $prepare = function($value) use(&$prepare, &$list) { if (is_array($value)) { return array_map($prepare, array_merge($list, $value)); } $list[] = $value; }; return false === array_walk(func_get_args(), $prepare, $list) ? 0 : addition(0, $list); } function addition($sum, array &$list) { return empty($list) ? $sum : addition($sum + array_pop($list), $list); } echo add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
based on e5iJq
Output for 7.2.0
55
Output for 7.0.0 - 7.1.10
Notice: Only variables should be passed by reference in /in/cR67D on line 13 55
Output for 5.3.17 - 5.6.28
Strict Standards: Only variables should be passed by reference in /in/cR67D on line 13 55