An array is a special variable that can hold multiple values at the same time. In PHP, an array can be created using the array() function or by using square brackets [].

Here is an example of creating an array using the array() function:

“`php
$fruits = array(“apple”, “banana”, “orange”);
“`

Here is an example of creating an array using square brackets []:

“`php
$fruits = [“apple”, “banana”, “orange”];
“`

Arrays in PHP can hold values of different types, such as strings, numbers, and even other arrays. The values in an array are called elements. Each element in the array has an index that starts from 0.

You can access individual elements in an array using their index. For example, to access the first element in the $fruits array:

“`php
echo $fruits[0]; // outputs “apple”
“`

To add a new element to an array, you can use the [] operator with the index you want to assign the value to:

“`php
$fruits[] = “grape”;
“`

To modify an existing element in an array, you can assign a new value to its index:

“`php
$fruits[0] = “pear”;
“`

To remove an element from an array, you can use the unset() function:

“`php
unset($fruits[1]);
“`

Arrays can also be nested, meaning an array can hold other arrays:

“`php
$fruits = [
[“apple”, “banana”],
[“orange”, “grape”],
[“lemon”, “lime”]
];
“`

You can access elements in nested arrays using multiple indices:

“`php
echo $fruits[0][1]; // outputs “banana”
“`

There are also many built-in PHP functions that can be used with arrays, such as count(), which returns the number of elements in an array:

“`php
echo count($fruits); // outputs 3
“`

PHP arrays are a powerful and flexible way to store and manipulate multiple values in a single variable.