Jump to Navigation

023 - Searching Array

The preg_grep() function searches all element of an array, returning an array consisting of all
elements matching a certain pattern.

Example:

$foods = array("pasta", "steak", "fish", "potatoes");
$food = preg_grep("/^p/", $foods);
print_f($food);


Main menu 2

Story | by Dr. Radut