Split into key/value array.
Note: 'slice of' elements if keys and values are not the same length.

@param string $string
@param string $separator
@param string[] $keys
@return string[]
972383
public static function splitIntoKeyValue(string $string, string $separator, array $keys): array
    {
        $parts = explode($separator, $string);
        $result = [];
        if (count($keys) > 0) {

            // Make sure arrays has equal number of items.
            if (count($parts) > count($keys)) {
                $parts = array_slice($parts, 0, count($keys));
            }
            if (count($keys) > count($parts)) {
                $keys = array_slice($keys, 0, count($parts));
            }

            $result = array_combine($keys, $parts);
        }
        return $result;
    }
1214976
public static function flattenArray(array $array, $separator = '_')
    {
        $resultArray = [];
        foreach ($array as $key => $val) {
            if (is_array($val)) {
                /* @noinspection AdditionOperationOnArraysInspection */
                $resultArray += self::prefixArray(self::flattenArray($val), $key, $separator);
            } else {
                $resultArray[$key] = $val;
            }
        }

        return $resultArray;
    }
1033430
private String [] split (final String string, final String delim)
  {
    final List <String> result = new ArrayList <> ();

    final StringTokenizer stringTokenizer = new StringTokenizer (string, delim);
    while (stringTokenizer.hasMoreTokens ())
    {
      result.add (stringTokenizer.nextToken ());
    }

    return result.toArray (new String [result.size ()]);
  }
948387
public static function format($string, $format, $separator = '/')
	{
		// Trim
		$string = trim($string, $separator);
		
		// Empty path case
		if ($string === '') {
			if ($format == self::FORMAT_BOTH_DELIMITERS) {
				return $separator;
			} else {
				return $string;
			}
		}
		
		// Add delimiters
		if ($format & self::FORMAT_LEFT_DELIMITER) {
			$string = $separator . $string;
		}
		if ($format & self::FORMAT_RIGHT_DELIMITER) {
			$string = $string . $separator;
		}
		
		return $string;
	}
291800
public static function encode($data, String $key = NULL, String $separator = NULL) : String
    {
        if( ! is_scalar($data) )
        {
            $data = (array) $data;
        }
        
        $word      = NULL;
        $key       = $key       ?: self::$key;
        $separator = $separator ?: self::$separator;
 
        foreach( $data as $k => $v )
        {
            $word .= self::_security($k).$key.self::_security($v).$separator;
        }

        return mb_substr($word, 0, -(mb_strlen($separator)));
    }
912814
public static String[] split(String s, String separator) {

        HsqlArrayList list      = new HsqlArrayList();
        int           currindex = 0;

        for (boolean more = true; more; ) {
            int nextindex = s.indexOf(separator, currindex);

            if (nextindex == -1) {
                nextindex = s.length();
                more      = false;
            }

            list.add(s.substring(currindex, nextindex));

            currindex = nextindex + separator.length();
        }

        return (String[]) list.toArray(new String[list.size()]);
    }
457253
public static function csplit($string, $delimiter = ',')
    {
        if (is_array($string)) {
            return $string;
        }
        $res = [];
        foreach (explode($delimiter, $string) as $k => $v) {
            $v = trim($v);
            if (strlen($v)) {
                array_push($res, $v);
            }
        }

        return $res;
    }
337639
function parseKeyValue (str, sep1, sep2) {
  var result = {}
  str.split(sep1).forEach(function (kv) {
    if (kv.length > 0) {
      kv = kv.split(sep2, 2)
      result[kv[0]] = parseValue(kv[1])
    }
  })
  return result
}
212875
public static function decodeObject(String $data, String $key = NULL, String $separator = NULL) : stdClass
    {
        return self::decode($data, $key, $separator);
    }
1081348
public static List<String> split(String str, char sepChr) {
    	List<String> result = new ArrayList<String>();
    	int idx = 0;
    	while(true) {
    		int idx2 = str.indexOf(sepChr, idx);
    		if(idx2 < 0) {
    			result.add(str.substring(idx));
    			break;
    		}
    		result.add(str.substring(idx, idx2));
    		idx = idx2 + 1;
    	}
        return result;
    }
22428
public static function unsetKey(array &$array, $namespace, $separator = '.')
    {
        if (!is_string($namespace)) {
            return $array;
        }

        $keys = explode($separator, $namespace);

        while (($count = count($keys)) > 0 and !is_null($array)) {
            $key = array_shift($keys);
            if (isset($array[$key])) {
                if ($count < 2) {
                    unset($array[$key]);
                } else {
                    $array =& $array[$key];
                }
            }
        }
    }
55189
public static function removeLast(string $string, string $separator): string
    {
        $string = explode($separator, $string);
        $string = Arr::removeLast($string);
        return implode($separator, $string);
    }
1204061
@Transformer
    public static String[] divide(Object o, String sep) {
        return str(o).split(sep);
    }
371445
public static function getNonEmptyValuesAsString(array $values, $separator = ', ')
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($values)) {
            return null;
        }

        $nonEmpty = self::getNonEmptyValues($values);

        /*
         * No values?
         * Nothing to do
         */
        if (empty($nonEmpty)) {
            return '';
        }

        return implode($separator, $nonEmpty);
    }
457275
protected function getArrayFromValue($value, $separator = ',')
    {
        if (!is_array($value)) {
            $value = explode($separator, $value);
        }

        return $value;
    }
609247
public static function dimensionizeArray($array, $separator = '.')
    {
        $dimArray = array();
        
        foreach ($array as $key => $value) {
            $key = trim($key, $separator);
            // checks if the key is a path
            if (strpos($key, $separator) !== false) {
                $parts = self::splitArrayPath($key, $separator);
                $firstPart = array_shift($parts);
                // recursively dimensionize the key
                $value = self::dimensionizeArray(array(implode($separator, $parts) => $value), $separator);
                
                if (isset($dimArray[$firstPart])) {
                    if (!is_array($dimArray[$firstPart])) {
                        // if $firstPart exists but is not an array, drops the value and use an array
                        $dimArray[$firstPart] = array();
                    }
                    // merge recursively both arrays
                    $dimArray[$firstPart] = self::mergeRecursive($dimArray[$firstPart], $value);
                } else {
                    $dimArray[$firstPart] = $value;
                }
                
            } else if (is_array($value)) {
                // dimensionize sub arrays
                $value = self::dimensionizeArray($value, $separator);
                if (isset($dimArray[$key])) {
                    $dimArray[$key] = self::mergeRecursive($dimArray[$key], $value);
                } else {
                    $dimArray[$key] = $value;
                }
            } else {
                $dimArray[$key] = $value;
            }
        }
        
        return $dimArray;
    }
453074
protected function _parseTag($string, array $keys = []) {
		$parts = explode(' ', $string, count($keys));
		$result = array_fill_keys($keys, null);

		foreach ($keys as $i => $key) {
			if (isset($parts[$i])) {
				if ($key === 'description') {
					$result[$key] = $this->_clean($parts[$i]);
				} else {
					$result[$key] = $parts[$i];
				}
			}
		}
		return $result;
	}