Skip to content
Snippets Groups Projects
Commit 1adf437f authored by Prasad's avatar Prasad
Browse files

Improved split* api compat to php7

parent d23ddb8f
No related branches found
No related tags found
No related merge requests found
......@@ -2306,15 +2306,28 @@ function lower_array(&$string){
}
/* PHP 7 support */
function php7_compat_split($delim, $str, $ignore_case=false) {
$splits = array();
while ($str) {
$pos = $ignore_case ? stripos($str, $delim) : strpos($str, $delim);
if ($pos !== false) {
$splits[] = substr($str, 0, $pos);
$str = substr($str, $pos + strlen($delim));
} else {
$splits[] = $str;
$str = false;
}
}
return $splits;
}
if (!function_exists('split')) {
function split($delim, $str) { return explode($delim, $str); }
function split($delim, $str) { return php7_compat_split($delim, $str); }
}
if (!function_exists('spliti')) {
function spliti($delim, $str) {
// TODO - Review backward compatibilty on use-cases.
$str = str_replace($delim, strtolower($delim), $str);
return explode(strtolower($delim), $str);
return php7_compat_split($delim, $str, true);
}
}
?>
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment