array_filter( ) filters elements through a function
array array_filter ( array arr [, function callback] )
<?
function endswithy($value) {
return (substr($value, -1) == 'y');
}
$people = array("Johnny", "Timmy", "Bobby", "Sam", "Tammy", "Joe");
$withy = array_filter($people, "endswithy");
var_dump($withy);
?>
Related examples in the same category