3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasNonEmptyArray(array $array): bool { try { array_walk_recursive( $array, fn($v, $k) => throw new Exception("Found element $k\n") ); return false; } catch (Exception $e) { echo $e->getMessage(); return true; } } $array = [ [ 'one' => [], 'two' => [ 'a' => [ 'foo' => [], ], 'b' => [] ], 'three' => [ 'c' => [ 'fizz' => 'buzz' ] ] ] ]; var_export(hasNonEmptyArray($array));

preferences:
24.26 ms | 405 KiB | 5 Q