public static function getValue($array, $key, $default = null)
    {
        if (!isset($array)) {
            return $default;
        }

        if ($key instanceof \Closure) {
            return $key($array, $default);
        }
        if (is_array($key)) {
            $lastKey = array_pop($key);
            foreach ($key as $keyPart) {
                $array = static::getValue($array, $keyPart);
            }
            $key = $lastKey;
        }
        if (is_array($array) && array_key_exists($key, $array)) {
            return $array[$key];
        }
        if (($pos = strrpos($key, '.')) !== false) {
            $array = static::getValue($array, substr($key, 0, $pos), $default);
            $key = substr($key, $pos + 1);
        }

        if (is_object($array) && property_exists($array, $key)) {
            return $array->{$key};
        } elseif (is_array($array)) {
            return array_key_exists($key, $array) ? $array[$key] : $default;
        } else {
            return $default;
        }
    }
public static function getValue($array, $key, $default = null)
    {
        if (!isset($array)) {
            return $default;
        }

        if ($key instanceof \Closure) {
            return $key($array, $default);
        }
        if (is_array($key)) {
            $lastKey = array_pop($key);
            foreach ($key as $keyPart) {
                $array = static::getValue($array, $keyPart);
            }
            $key = $lastKey;
        }
        if (is_array($array) && array_key_exists($key, $array)) {
            return $array[$key];
        }
        if (($pos = strrpos($key, '.')) !== false) {
            $array = static::getValue($array, substr($key, 0, $pos), $default);
            $key = substr($key, $pos + 1);
        }

        if (is_object($array) && property_exists($array, $key)) {
            return $array->{$key};
        } elseif (is_array($array)) {
            return array_key_exists($key, $array) ? $array[$key] : $default;
        } else {
            return $default;
        }
    }
public static function getValue ( $ array , $ key , $ default = null ) { if ( ! isset ( $ array ) ) { return $ default ; } if ( $ key instanceof \ Closure ) { return $ key ( $ array , $ default ) ; } if ( is_array ( $ key ) ) { $ lastKey = array_pop ( $ key ) ; foreach ( $ key as $ keyPart ) { $ array = static :: getValue ( $ array , $ keyPart ) ; } $ key = $ lastKey ; } if ( is_array ( $ array ) && array_key_exists ( $ key , $ array ) ) { return $ array [ $ key ] ; } if ( ( $ pos = strrpos ( $ key , '.' ) ) !== false ) { $ array = static :: getValue ( $ array , substr ( $ key , 0 , $ pos ) , $ default ) ; $ key = substr ( $ key , $ pos + 1 ) ; } if ( is_object ( $ array ) && property_exists ( $ array , $ key ) ) { return $ array -> { $ key } ; } elseif ( is_array ( $ array ) ) { return array_key_exists ( $ key , $ array ) ? $ array [ $ key ] : $ default ; } else { return $ default ; } }
Gets value from array or object
Copied from Yii2 framework
@link http://www.yiiframework.com/
@copyright Copyright (c) 2008 Yii Software LLC
@license http://www.yiiframework.com/license/
@param      $array
@param      $key
@param null $default
@return null
@author Qiang Xue <qiang.xue@gmail.com>
@author Adegoke Obasa <goke@cottacush.com>
@author Rotimi Akintewe <rotimi.akintewe@gmail.com>
Gets value from array or object Copied from Yii2 framework