1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 17:23:00 +00:00

Account for missing ms_stripos

This commit is contained in:
Starbeamrainbowlabs 2015-11-02 14:20:06 +00:00
parent 173a72fa46
commit 98fff659a3

View file

@ -255,6 +255,33 @@ function starts_with($haystack, $needle)
return (substr($haystack, 0, $length) === $needle);
}
/**
* mb_stripos all occurences
* from http://www.pontikis.net/tip/?id=16
* based on http://www.php.net/manual/en/function.strpos.php#87061
*
* Find all occurrences of a needle in a haystack (case-insensitive, UTF8)
*
* @param string $haystack
* @param string $needle
* @return array or false
*/
function mb_stripos_all($haystack, $needle) {
$s = 0; $i = 0;
while(is_integer($i)) {
$i = function_exists("mb_stripos") ? mb_stripos($haystack, $needle, $s) : stripos($haystack, $needle, $s);
if(is_integer($i)) {
$aStrPos[] = $i;
$s = $i + (function_exists("mb_strlen") ? mb_strlen($needle) : strlen($needle));
}
}
if(isset($aStrPos))
return $aStrPos;
else
return false;
}
function system_mime_type_extensions() {
global $settings;
# Returns the system MIME type mapping of MIME types to extensions, as defined in /etc/mime.types (considering the first