What is the difference between:

array_key_exists('bar', $foo)

Is there a performance difference? Is one way more correct than the other?

The difference is that if bar is null isset() will return FALSE, while array_key_exists() will still return TRUE:

$foo['bar'] = NULL;

echo isset($foo['bar']) ? 'true':'false';
echo array_key_exists('bar',$foo) ? 'true':'false';

So it depends on your intentions.

commented: never knew that +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.