Elements
is the name of the data on the array and the location of each of the elements
indicated by an index. Array starting at index 0. Array has two boundaries, the
lower limit and upper limit.
The dimensions
of the array can be one or more dimensions. Some examples dimensional array:
a.
One-dimensional Array (representing vector shapes)
b.
Two-dimensional array (representing the matrix form)
c.
Three-dimensional array (representing the shape of the room)
Writing array
syntax:
Array[];
$variabelname=$array(“elemen0”,”elemen1”,”elemen2”,”elemen..n”);
Example:
1. The first form of
array declaration
$flower[ ]=”Roses”;
$flower[ ]=”Orchid”;
$flower[ ]=”Jasmine”;
$flower[ ]=”Sunflower”;
print($flower[2]);
The result is Jasmine
2. The second form of
array declaration
$flower=array(“Roses”,”Orchid”,”Jasmine”,”Sunflower”);
Print($flower[1]);
The result is Orchid
No comments:
Post a Comment