Skip to content

Instantly share code, notes, and snippets.

@ljungmark
Created September 23, 2016 17:14
Show Gist options
  • Save ljungmark/2ddae7c051fb09cf54291e1d32ea5fb3 to your computer and use it in GitHub Desktop.
Save ljungmark/2ddae7c051fb09cf54291e1d32ea5fb3 to your computer and use it in GitHub Desktop.
Perform partial match to string values in an array
<?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