Define an Array in PHP

An array is an ordered list of data. PHP arrays are associative, meaning that you can access the data by its key rather than its position in the array.

PHP arrays can be used for a variety of purposes. They can be treated as simple arrays, lists, hash tables, dictionaries, collections, stacks, or queues. Additionally, they can be used to store other arrays, trees, or multidimensional arrays. This makes PHP arrays extremely versatile and flexible. While they may not be the best choice for every situation, they can certainly be adapted to meet a wide range of needs. As a result, PHP arrays are often the go-to choice for many developers.

Arrays can be created using the array function or the square brackets:

$fruit = array('apple','banana','orange','mango');
$fruit = ['apple','banana','orange','mango'];
$settings = [
    'send_from_phone' => '',
    'days_before_notify' => '0',
    'time_to_notify' => '09:00',
    'send_from_email' => ''
$settings = [
    'receipents' => ['[email protected]', '[email protected]', '[email protected]'],
    'working_days' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.