You can create an array using either the array() function or the array operator [].The array() function is usually used when you want to create a new array and populate it with more than one element, all in one fell swoop. The array operator is often used when you want to create a new array with just one element at the outset, or when you want to add to an existing array element.
The following code snippet shows how to create an array called $rainbow using the array() function, containing all its various colors:
$rainbow = array("red", "orange", "yellow", "green", "blue", "indigo", "violet");