- var_export: documentation ( source)
- array_filter: documentation ( source)
- str_starts_with: documentation ( source)
<?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
)
);