Adsense 728 * 15


Custom Search

Array in PHP

PHP Array

What is an array?

An Array is used to store multiple values. 

There are three kinds of array in PHP

1. Numeric array
2. Associative array
3. Multidimensional array

Numeric array in php

In numeric array we store each array with numeric index.

Example of Numeric array


$array = array( "amit", "kamal", "vikash","robin","ram" ); //array declaration

//Below each array item is called by it's numeric index
echo $array[0];   
echo $array[1];   
echo $array[2]; 
echo $array[3]; 
echo $array[4]; 

In array index starts from zero. so $array[0] point to amit, $array[1] points to kamal and so on.

You can also declare array by intialising one-by-one

$array[0] = "amit";
$array[1] = "kamal";
$array[2] = "vikash";
$array[3] = "robin";
$array[4] = "ram";

No comments:

Post a Comment