How can I filter an array when a sub element starts with a certain string? This will filter results when 'name' matches 'bk-' but how can I alter it so matched elements starting with 'bk-' instead?
$starts_with = 'bk-';
$new_facets = array_filter($facets, function ($var) use ($starts_with) {
return ($var['name'] == $starts_with);
});
No comments:
Post a Comment