PHP - Indexed Array

A indexed array stores each array element with a numeric index.there are two methods to create a numeric array.the following example the index are automatically assigned.


<?php
   $number = array("one","two","three");
?>								
							

The following example we assign the index manually.


<?php
	$number[0] = "one";
	$number[1] = "two";
	$number[2] = "three";
?>							
							

The following example you access the variable values by referring to the array name and index.


<?php
	$number[0] = "one";
	$number[1] = "two";
	$number[2] = "three";
	echo $number[0]."-".$number[1]."-".$number[2]."and"."four";
?>									
							

Output


one-two-threeandfour							
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!