<span style="color: #008000">/*</span><span style="color: #008000">**********array_key_exists(检查键名或索引是否在数组中)****************</span><span style="color: #008000">*/</span> <span style="color: #800080">$arr1</span> = <span style="color: #0000ff">array</span>('name' => 'Sheldon', 'age' => 30, 'address' => 'Carlifornia'<span style="color: #000000">); </span><span style="color: #0000ff">if</span> (<span style="color: #008080">array_key_exists</span>('name', <span style="color: #800080">$arr1</span><span style="color: #000000">)) { </span><span style="color: #0000ff">echo</span> 'the name element is in the array.'<span style="color: #000000">; } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { </span><span style="color: #0000ff">echo</span> 'name elment not exist.'<span style="color: #000000">; }</span>
Check if there is a key named 'name' in $arr1.
Also check the numerical index.