3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = ['foo' => 'bar']; $newArr = []; foreach (['foo', 'test'] as $key) { $arr[$key] ?? $newArr[] = $arr[$key]; } var_dump($newArr);

preferences:
46.51 ms | 1389 KiB | 5 Q