Re-added mb_stripos_all. How on earth did THAT get removed?!

This commit is contained in:
Starbeamrainbowlabs 2015-11-09 07:30:00 +00:00
parent e7dfda5f75
commit 97391466ed
2 changed files with 50 additions and 0 deletions

View File

@ -614,6 +614,31 @@ function starts_with($haystack, $needle)
$length = strlen($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;

View File

@ -276,6 +276,31 @@ function starts_with($haystack, $needle)
$length = strlen($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;