3v4l.org

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

preferences:
30.57 ms | 404 KiB | 5 Q