Associative array/Creation: Difference between revisions

Line 1,981:
$array2 = ['fruit' => 'apple',
'price' => 12.96,
'colour' => 'green'];</lang>
 
// Check if key exists in the associative array
echo(isset($array['foo'])); // Faster, but returns false if the value of the element is set to null
echo(array_key_exists('foo', $array)); // Slower, but returns true if the value of the element is null</lang>
 
===Iterate over key/value===
Anonymous user