PHP Example HTML Javascript jQuery Ajax CSS Java MORE

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];
?>

Run It Yourself »

Output

30
50
55

Get The Length of an Array

Example

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

Run It Yourself »

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";
}
?>

Run It Yourself »

Output

12345678910