3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['key1' => 5, 'key2' => 17]; $array = array_filter($array, function ($value, $key) { return !!preg_match('/^key\d$/', $key); });

preferences:
56.22 ms | 402 KiB | 5 Q