3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function arraySum(array $array) { $stack = [$array]; $sum = 0; while (($items = array_pop($stack))) { foreach ($items as $item) { if (is_array($item)) { $stack[] = $item; } else { $sum += $item; } } } return $sum; } echo arraySum([1, [1, 1], [1, [1, 1]]]);
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.1.7
6