src/util/Arr.php
public static function path($array, $path, $default = null, $delimiter = null) {
        if (!static::is_array($array)) {
            // This is not an array!
            return $default;
        }

        if (is_array($path)) {
            // The path has already been separated into keys
            $keys = $path;
        } else {
            if (array_key_exists($path, $array)) {
                // No need to do extra processing
                return $array[$path];
            }

            if (!$delimiter) {
                // Use the default delimiter
                $delimiter = static::$delimiter;
            }

            // Remove  delimiters and spaces
            $path = trim($path, "{$delimiter} ");

            // Split the keys by delimiter
            $keys = explode($delimiter, $path);
        }

        do {
            $key = array_shift($keys);

            if (ctype_digit($key)) {
                // Make the key an integer
                $key = (int)$key;
            }

            if (isset($array[$key])) {
                if (!$keys) {
                    // Found the path requested
                    return $array[$key];
                }
                if (!static::is_array($array[$key])) {
                    // Unable to dig deeper
                    break;
                }
                // Dig down into the next part of the path
                $array = $array[$key];
            } else {
                // Unable to dig deeper
                break;
            }
        } while ($keys);

        // Unable to find the value requested
        return $default;
    }
public static function path($array, $path, $default = null, $delimiter = null) {
        if (!static::is_array($array)) {
            // This is not an array!
            return $default;
        }

        if (is_array($path)) {
            // The path has already been separated into keys
            $keys = $path;
        } else {
            if (array_key_exists($path, $array)) {
                // No need to do extra processing
                return $array[$path];
            }

            if (!$delimiter) {
                // Use the default delimiter
                $delimiter = static::$delimiter;
            }

            // Remove  delimiters and spaces
            $path = trim($path, "{$delimiter} ");

            // Split the keys by delimiter
            $keys = explode($delimiter, $path);
        }

        do {
            $key = array_shift($keys);

            if (ctype_digit($key)) {
                // Make the key an integer
                $key = (int)$key;
            }

            if (isset($array[$key])) {
                if (!$keys) {
                    // Found the path requested
                    return $array[$key];
                }
                if (!static::is_array($array[$key])) {
                    // Unable to dig deeper
                    break;
                }
                // Dig down into the next part of the path
                $array = $array[$key];
            } else {
                // Unable to dig deeper
                break;
            }
        } while ($keys);

        // Unable to find the value requested
        return $default;
    }
public static function path ( $ array , $ path , $ default = null , $ delimiter = null ) { if ( ! static :: is_array ( $ array ) ) { // This is not an array! return $ default ; } if ( is_array ( $ path ) ) { // The path has already been separated into keys $ keys = $ path ; } else { if ( array_key_exists ( $ path , $ array ) ) { // No need to do extra processing return $ array [ $ path ] ; } if ( ! $ delimiter ) { // Use the default delimiter $ delimiter = static :: $ delimiter ; } // Remove  delimiters and spaces $ path = trim ( $ path , "{$delimiter} " ) ; // Split the keys by delimiter $ keys = explode ( $ delimiter , $ path ) ; } do { $ key = array_shift ( $ keys ) ; if ( ctype_digit ( $ key ) ) { // Make the key an integer $ key = ( int ) $ key ; } if ( isset ( $ array [ $ key ] ) ) { if ( ! $ keys ) { // Found the path requested return $ array [ $ key ] ; } if ( ! static :: is_array ( $ array [ $ key ] ) ) { // Unable to dig deeper break ; } // Dig down into the next part of the path $ array = $ array [ $ key ] ; } else { // Unable to dig deeper break ; } } while ( $ keys ) ; // Unable to find the value requested return $ default ; }
Gets a value from an array using a dot separated path.

// Get the value of $array['foo']['bar']
$value = Arr::path($array, 'foo.bar');

@param   array $array array to search
@param   mixed $path key path string (delimiter separated) or array of keys
@param   mixed $default default value if the path is not set
@param   string $delimiter key path delimiter
@return  mixed
Gets a value from an array using a dot separated path .