Arrays
We talk about what variables are in previus tutorial today we will learn what an array is and what we can do with it.
An array is a variable that can hold more than one value at a time, think that an array is a list it has a name, index and value.
to declare an array is very easy in php and can save you time:
While holding simple information like name and surname is ok but if you want to retrieve information from database then you have to use an array.
Declare of an array:
Alternative:
Retrieve values:
We talk about what variables are in previus tutorial today we will learn what an array is and what we can do with it.
An array is a variable that can hold more than one value at a time, think that an array is a list it has a name, index and value.
to declare an array is very easy in php and can save you time:
While holding simple information like name and surname is ok but if you want to retrieve information from database then you have to use an array.
Declare of an array:
$phones = array("nokia", "sony erricson", "htc");
Alternative:
$phones[0] = "nokia";
$phones[1] = "sony erricson";
$phones[2] = "htc";
Retrieve values:
<?php
echo $phones[0];
echo "</br>";
echo $phones[1];
echo "</br>";
echo $phones[2];
echo "</br>";
?>
No comments:
Post a Comment