How can i filter this array values [Name] => try to match word “Good” beginning of the values name
Array
(
[0] => Array
(
[Name] => Good Seat
[image] => spot
[category] => 0
)
[1] => Array
(
[Name] => Nice Good Service
[image] => spotless
[category] => 0
)
[2] => Array
(
[Name] => Good Work
[image] => spotly
[category] => 1
)
)
I need filter like this
Array
(
[0] => Array
(
[Name] => Good Seat
[image] => spot
[category] => 0
)
[1] => Array
(
[Name] => Good Work
[image] => spotly
[category] => 1
)
)
My Code
function name($var)
{
return (is_array($var) && $var['Name'] == preg_match("/^Good/", $var['Name']));
}
print_r(array_filter($var, "name"));
thanks.
remove the $var[‘Name’]=