PHP – Array



Array is a special kind of variable which is able to store more than one variable simultaneously.

<?php $data=array("30","50","55"); echo $data[0]." "; echo $data[1]." "; echo $data[2]; ?>

Output

30
50
55

Get The Length of an Array

<?php $data=array("30","50","55"); echo count($data); ?>

Output
3

How to assign element in array?

<?php
$data=array();
for($i=0;$i<=10;$i++)
{
$data[$i]=$i;
}
foreach($data as $element)
{
echo "$element";
}
?>