preg_grep : preg_grep « String « PHP






preg_grep

 
<?php
   $foods = array("pasta", "steak", "fish", "potatoes");
   $food = preg_grep("/^p/", $foods);
   print_r($food);
?>
  
  








Related examples in the same category

1.preg_grep() function searches all elements of input_array, returning all elements matching the regexp pattern.
2.Using preg_grep()
3.Quickly finding lines that match a pattern