protected function setArrayElementByKey($array, $setKey, $setVal)
    {
        $link = &$array;
        $keyParts = explode(':', $setKey);
        foreach ($keyParts as $key) {
            if (
                is_numeric($key)
                && (string)((integer)$key) === $key
            ) {
                $key = (integer)$key;
            }
            if (!isset($link[$key])) {
                $link[$key] = [];
            }
            $link = &$link[$key];
        }
        $link = $setVal;

        return $array;
    }
protected function setArrayElementByKey($array, $setKey, $setVal)
    {
        $link = &$array;
        $keyParts = explode(':', $setKey);
        foreach ($keyParts as $key) {
            if (
                is_numeric($key)
                && (string)((integer)$key) === $key
            ) {
                $key = (integer)$key;
            }
            if (!isset($link[$key])) {
                $link[$key] = [];
            }
            $link = &$link[$key];
        }
        $link = $setVal;

        return $array;
    }
protected function setArrayElementByKey ( $ array , $ setKey , $ setVal ) { $ link = & $ array ; $ keyParts = explode ( ':' , $ setKey ) ; foreach ( $ keyParts as $ key ) { if ( is_numeric ( $ key ) && ( string ) ( ( integer ) $ key ) === $ key ) { $ key = ( integer ) $ key ; } if ( ! isset ( $ link [ $ key ] ) ) { $ link [ $ key ] = [ ] ; } $ link = & $ link [ $ key ] ; } $ link = $ setVal ; return $ array ; }
set value in array by key

$setKey example: 'key:123:array' => $_SESSION['key'][123]['array']

@param array $array
@param string $setKey
@param mixed  $setVal

@return array
set value in array by key