3v4l.org

run code in 300+ PHP versions simultaneously
<?php function breadcrumb($array) { $output = []; foreach ($array as $key => $value) { if (is_array($value)) { foreach (breadcrumb($value) as $breadcrumb) { $output[] = $key . ' > ' . $breadcrumb; } } else { $output[] = $key; } } return $output; } $array = [ 'note' => [ 'to' => [ 'user' => [ 'name' => 'First user', ], 'abc' => 123, 'lmn' => 4582, ], 'from' => 'Jani', 'heading' => 'Reminder', 'body' => [ 'abc' => 123 ] ] ]; var_dump(breadcrumb($array));

preferences:
33.15 ms | 404 KiB | 5 Q