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.
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.
It's Excellent php related blog. I liked it.
ReplyDeletePHP Training
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
ReplyDeleteoriented. So, if you are looking for professional PHP
training in Kolkata, acesoftech
is the best choice for you.