Monday, March 21, 2011

Numeric Arrays

 A numeric array stores each array element with a numeric index.
 There are two methods to create a numeric array.
1.In the following example the index ae automatically assigned (the index stars at 0):
   $cars=array ("Saab","Volvo","BMW","Toyota");
2.In the following example we assign the index manually:
   $cars[0]="Saab"
   $cars[1]="Volvo";
   $cars[2]="BMW";
   $cars[3]="Toyota";
Example
In the following example you access the variables by reffering to the array name and index.
<?php
$cars[0]="Saab";
$cars[1]="Volvo";
$cars[2]="BMW";
$cars[3]="Toyota";
echo $cars[0] . "and" . $cars[1] . "are Swedish cars.";
?>
The code above will output:
Saab and Volvo are Swedish cars.

2 comments:

  1. Acesoftech is No.1 PHP training center in kolkata. Our professional trainer can provide you PHP training in such a way that it will be complete job

    oriented. So, if you are looking for professional PHP

    training in Kolkata
    , acesoftech
    is the best choice for you.

    ReplyDelete