ConsoleKit\Utils::get PHP Method

get() public static method

Returns the value from $key in $array or $default
public static get ( array $array, string $key, mixed $default = null ) : mixed
$array array
$key string
$default mixed
return mixed
    public static function get($array, $key, $default = null)
    {
        if (array_key_exists($key, $array)) {
            return $array[$key];
        }
        return $default;
    }

Usage Example

Esempio n. 1
0
 public function testGet()
 {
     $data = array('foo' => 'bar');
     $this->assertEquals('bar', Utils::get($data, 'foo'));
     $this->assertNull(Utils::get($data, 'unknown'));
     $this->assertEquals('default', Utils::get($data, 'unknown', 'default'));
 }
All Usage Examples Of ConsoleKit\Utils::get