src/Utilities/Arrays.php
public static function string2array($string, $separator = '|', $valuesKeysSeparator = ':')
    {
        /*
         * Empty string?
         * Nothing to do
         */
        if (empty($string)) {
            return null;
        }

        $array = [];
        $exploded = explode($separator, $string);

        foreach ($exploded as $item) {
            $exploded2 = explode($valuesKeysSeparator, $item);

            if (2 === count($exploded2)) {
                $key = trim($exploded2[0]);
                $value = trim($exploded2[1]);

                $array[$key] = $value;
            }
        }

        return $array;
    }
public static function string2array($string, $separator = '|', $valuesKeysSeparator = ':')
    {
        /*
         * Empty string?
         * Nothing to do
         */
        if (empty($string)) {
            return null;
        }

        $array = [];
        $exploded = explode($separator, $string);

        foreach ($exploded as $item) {
            $exploded2 = explode($valuesKeysSeparator, $item);

            if (2 === count($exploded2)) {
                $key = trim($exploded2[0]);
                $value = trim($exploded2[1]);

                $array[$key] = $value;
            }
        }

        return $array;
    }
public static function string2array ( $ string , $ separator = '|' , $ valuesKeysSeparator = ':' ) { /*
         * Empty string?
         * Nothing to do
         */ if ( empty ( $ string ) ) { return null ; } $ array = [ ] ; $ exploded = explode ( $ separator , $ string ) ; foreach ( $ exploded as $ item ) { $ exploded2 = explode ( $ valuesKeysSeparator , $ item ) ; if ( 2 === count ( $ exploded2 ) ) { $ key = trim ( $ exploded2 [ 0 ] ) ; $ value = trim ( $ exploded2 [ 1 ] ) ; $ array [ $ key ] = $ value ; } } return $ array ; }
Converts given string with special separators to array

Example:
~ string:
"light:jasny|dark:ciemny"

~ array as a result:
[
'light' => 'jasny',
'dark'  => 'ciemny',
]

@param string $string              The string to be converted
@param string $separator           (optional) Separator used between name-value pairs in the string.
Default: "|".
@param string $valuesKeysSeparator (optional) Separator used between name and value in the string. Default: ":".
@return array
Converts given string with special separators to array