From 1adf437f5c02380d8968047733de3e028ab8d54f Mon Sep 17 00:00:00 2001
From: prasad <prasad@vtiger.com>
Date: Wed, 13 Jul 2016 17:06:33 +0530
Subject: [PATCH] Improved split* api compat to php7

---
 include/utils/utils.php | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/include/utils/utils.php b/include/utils/utils.php
index 5768bf84e..cae8e2a74 100755
--- a/include/utils/utils.php
+++ b/include/utils/utils.php
@@ -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
-- 
GitLab