Skip to content

Instantly share code, notes, and snippets.

@mrbobbybryant
Last active August 29, 2015 14:21
Show Gist options
  • Save mrbobbybryant/2a68c60ce8dd5d98eee4 to your computer and use it in GitHub Desktop.
Save mrbobbybryant/2a68c60ce8dd5d98eee4 to your computer and use it in GitHub Desktop.
array_filter example
<?php
//Allows you to difine your own callback function to uniquely filter an array.
function endswithy($value) {
return (substr($value, -1) == 'y');
}
//This example returns an array of people who's names end in "y"
$people = array("Johnny", "Timmy", "Bobby", "Sam", "Tammy", "Danny", "Joe");
$withy = array_filter($people, "endswithy");
var_dump($withy);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment