Skip to content

Instantly share code, notes, and snippets.

@mdeora
Forked from msng/strpos_array.php
Created December 28, 2017 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdeora/80d4476bbd29e2c51a137f1b4dd50cff to your computer and use it in GitHub Desktop.
Save mdeora/80d4476bbd29e2c51a137f1b4dd50cff to your computer and use it in GitHub Desktop.
PHP: strpos_array is strpos that can take an array as needle
<?php
function strpos_array($haystack, $needles, $offset = 0) {
if (is_array($needles)) {
foreach ($needles as $needle) {
$pos = strpos_array($haystack, $needle);
if ($pos !== false) {
return $pos;
}
}
return false;
} else {
return strpos($haystack, $needles, $offset);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment