Created
September 23, 2016 17:14
-
-
Save ljungmark/2ddae7c051fb09cf54291e1d32ea5fb3 to your computer and use it in GitHub Desktop.
Perform partial match to string values in an array
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 | |
function partial_match($needle, $haystack) { | |
if(!is_array($haystack)) return false; | |
foreach ($haystack as $key=>$item) { | |
if (strpos($item, $needle) !== false) return true; | |
} | |
return false; | |
} | |
// $partial_match = partial_match('string', array()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment