What is the correct syntax for creating an array in PHP?

To create an array in PHP, you can use the array() function or the shorthand [] syntax. The array() function allows you to define an array with key-value pairs, while the [] syntax is more concise and commonly used for creating indexed arrays. Both methods are valid and can be used depending on your specific needs.

// Using the array() function to create an array with key-value pairs
$person = array("name" => "John", "age" => 30, "city" => "New York");

// Using the shorthand [] syntax to create an indexed array
$fruits = ["apple", "banana", "orange"];