preg_grep :- This is a function dedicated for just searching elements that matches given regular expression. It will take a regular expression as first parameter, and an array as the second.
example :-
<?php
$demo = array (
'hi guys',
'hi silicon',
'hello india',
'siliconindia'
);
$matches = preg_grep ('/^hi (\w+)/i', $demo);
print_r($matches);
?>
Thanks
Mar 22, 2015