private static function recursiveSetFromKey($data, $key, $value)
    {
        if (empty($key)) {
            return $value;
        } else {
            if (!is_array($data)) {
                $data = [];
            }
            $currentKey = array_shift($key);

            if (!isset($data[$currentKey])) {
                $data[$currentKey] = [];
            }

            $data[$currentKey] = self::recursiveSetFromKey($data[$currentKey], $key, $value);
            return $data;
        }
    }
private static function recursiveSetFromKey($data, $key, $value)
    {
        if (empty($key)) {
            return $value;
        } else {
            if (!is_array($data)) {
                $data = [];
            }
            $currentKey = array_shift($key);

            if (!isset($data[$currentKey])) {
                $data[$currentKey] = [];
            }

            $data[$currentKey] = self::recursiveSetFromKey($data[$currentKey], $key, $value);
            return $data;
        }
    }
private static function recursiveSetFromKey ( $ data , $ key , $ value ) { if ( empty ( $ key ) ) { return $ value ; } else { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } $ currentKey = array_shift ( $ key ) ; if ( ! isset ( $ data [ $ currentKey ] ) ) { $ data [ $ currentKey ] = [ ] ; } $ data [ $ currentKey ] = self :: recursiveSetFromKey ( $ data [ $ currentKey ] , $ key , $ value ) ; return $ data ; } }
Private unsecured method to set data in array

@param $data
@param $key
@param $value

@return array
Private unsecured method to set data in array