CascadiaPHP 2024

Voting

The Note You're Voting On

Jeroen
1 year ago
Be aware of the difference between checking the *value* of an array item, and checking the *existence* of an array item:
<?php
$arr
= [
'x' => 0,
'y' => null,
];

isset(
$arr['x']); // true, same as isset(0)
isset($arr['y']); // false, same as isset(null)

array_key_exists('y', $arr); // true, though the value is null
array_key_exists('z', $arr); // false

<< Back to user notes page

To Top