Wednesday, January 31, 2018

php - Filter array by sub element that starts with string

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...