Menu

Need MCA Or B.tech College Project Contact Us: +91 9437911966 (Whatsapp) Students Tutorial


PHP Array


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

Example

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

Output

30
50
55

Get The Length of an Array

Example

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

Output

3

How to assign element in array?

Example

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

Output

12345678910