What is an Array

An array is a collection of values with different data types

An array can be created using the array() language construct. It takes any number of comma-separated key => value pairs as arguments.

Syntax:

array(
    key  => value,
    key2 => value2,
    key3 => value3,
    ...
)


<?php
$array = array(
"foo" => "bar",
"bar" => "foo",
);
// as of PHP 5.4
$array = [
“foo” => “bar”,
“bar” => “foo”,
];
?>

 

Share this post