Question whether given array has given key

array:has_key?(ARRAY $array, $key) : BOOL

array:has_key?(["name" => "SunSed","version" => 4], "name")
#=> TRUE

array:has_key?(["name" => "SunSed","version" => 4], "foo")
#=> FALSE

# it is case sensitive
array:has_key?(["name" => "SunSed","version" => 4], "Name")
#=> FALSE

array:has_key?(["hi","bye"],0)
#=> TRUE

array:has_key?(["name" => "SunSed","version" => 4],0)
#=> FALSE

array:has_key?([],0)
#=> FALSE

# note: array keys can only be of type_string or type_integer
[1.2 => 'hi']
#=> [ 1 => "hi" ]

[true => 'hi', false => 'bye']
#=> [ 1 => "hi", 0 => "bye" ]

['1' => 'now']
#=> [ 1 => "now" ]

array:has_key?([1=>'hi'],true)
#=> TRUE

# note: array keys that contain numbers will become type_number
array:has_key?(["1"=>'hi'],1)
#=> TRUE

array:has_key?(["1"=>'hi'],"1")
#=> TRUE

array:has_key?(["1"=>'hi'],1.0)
#=> TRUE

Copyright ©2013-2022 SunSed®. All rights reserved.