3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'abc' => 0, 'foo-bcd' => 1, 'foo-def' => 1, 'foo-xyz' => 0, ]; $prefix = 'foo'; var_export( array_filter( $array, fn($key) => str_starts_with($key, $prefix), ARRAY_FILTER_USE_KEY ) );

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
177.68 ms | 2138 KiB | 13 Q