Skip to content

Instantly share code, notes, and snippets.

@fhferreira
Last active December 19, 2015 16:48
Show Gist options
  • Select an option

  • Save fhferreira/5986118 to your computer and use it in GitHub Desktop.

Select an option

Save fhferreira/5986118 to your computer and use it in GitHub Desktop.
<?php
/* strpos that takes an array of values to match against a string
* note the stupid argument order (to match strpos)
*/
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment