- substr: documentation ( source)
- print_r: documentation ( source)
- array_filter: documentation ( source)
<?php
$starts_with = 'bk-';
$facets = [
['name' => 'bk-0001'],
['name' => 'bk-0002'],
['name' => 'bx-0001']
];
$new_facets = array_filter($facets, function ($var) use ($starts_with) {
return substr($var['name'], 0, strlen($starts_with)) === $starts_with;
});
print_r($new_facets);