Last active
August 29, 2015 14:21
-
-
Save mrbobbybryant/2a68c60ce8dd5d98eee4 to your computer and use it in GitHub Desktop.
array_filter example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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