Multiple choice

Which one is correct for creating array?

  1. array([key=>] value,.......)

  2. array)key=>value,.........)

  3. Both (1) and (2)

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

PHP arrays are created using array() with optional key-value pairs: array('key' => 'value', 'key2' => 'value2'). The => operator associates keys with values. Modern PHP also supports the shorter [] syntax.