<?php
$test = ['a' => 1, 'b' => null];
echo "array_key_exists:\n";
echo array_key_exists('a', $test) ? "a: found\n" : "a: not found\n";
echo array_key_exists('b', $test) ? "b: found\n" : "b: not found\n";
echo "\n\nisset:\n";
echo isset($test['a']) ? "a: found\n" : "a: not found\n";
echo isset($test['b']) ? "b: found\n" : "b: not found\n";
echo "\n\nempty:\n";
echo empty($test['a']) ? "a: found\n" : "a: not found\n";
echo empty($test['b']) ? "b: found\n" : "b: not found\n";
- Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
- array_key_exists:
a: found
b: found
isset:
a: found
b: not found
empty:
a: not found
b: found
preferences:
81.22 ms | 408 KiB | 5 Q