PHP Preg_Grep() Function Searches All Elements Of Input_Array, Returning All Elements Matching Regexp Pattern. – String Function

 
Its syntax is: array preg_grep (string pattern, array input_array)<?
$foods = array("pasta", "steak", "fish", "potatoes");
$p_foods = preg_grep("/p(\w+)/", $foods);$x = 0;while ($x < sizeof($p_foods)) :
   print $p_foods[$x]. "<br />";
   $x++;
endwhile;
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.