Created
March 24, 2014 14:38
-
-
Save graymic/a5074ff85d50d3585fde to your computer and use it in GitHub Desktop.
Allows for multiple delimiters in a string pos function.
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
$str_pos_array = function ($haystack, $needles=[], $offset=0) { | |
$characters = []; | |
foreach($needles as $needle) { | |
$res = strpos($haystack, $needle, $offset); | |
if ($res !== false) { | |
$characters[$needle] = $res; | |
} | |
} | |
if(empty($characters)) { | |
return false; | |
} | |
return min($characters); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
$url = substr($url, 0, $strposarray($url, array("&", "?")));
Will strip the url after the & and ? delimiters.