Introduction to Arrays in PHP

Estudies4you
Introduction to Arrays in PHP

Array - Introduction

Introduction to Arrays in PHP


An Array in PHP is an ordered map. A map associates values to keys
The values in the array can be accessed by using these keys. An array can hold multiple values

Creating Arrays
In PHP, an array is created using the array() function. Values are assigned to the keys, which are numbered from 0.

Syntax
$i=array("valuel","value2","value3"...);
Example:
<?php
$i=array("chocolates","biscuits","bread");
echo "I love to have " . $i[0] . ", " . $i[1] . " or " .$i[2]. " for breakfast.";
?>


To Top