$cars = array('honda','toyoda','hhh');
echo count($cars);
Result :
3
$cars = array('honda','toyoda','hhh');
print_r($cars);
Result :
Array
(
[0] => honda
[1] => toyoda
[2] => hhh
)
$cars = array('honda','toyoda','hhh');
var_dump($cars);
Result :
array(3) {
[0]=>
string(5) "honda"
[1]=>
string(6) "toyoda"
[2]=>
string(3) "hhh"
}
$people = array('Brad'=>35,'jhon'=>44);
$ids = array(22 => 'brad', 55 =>'sam');
echo $people['Brad'];
Result :
35
$people = array('Brad'=>35,'jhon'=>44);
$ids = array(22 => 'brad', 55 =>'sam');
print_r($people);
Result :
Array
(
[Brad] => 35
[jhon] => 44
)
array(2) {
[22]=>
string(4) "brad"
[55]=>
string(3) "sam"
}
--> FOR LOOP
for($i = 5; $i <= 10;$i++){
echo $i;
echo '
';
}
Result :
5
6
7
8
9
10
--> WHILE LOOP
$j = 0;
while($j < 10){
echo $j;
echo '
';
$j++;
}
Result :
0
1
2
3
4
5
6
7
8
9
--> FOREACH
$people = array('brad','josh','will');
foreach($people as $person){
echo $person;
echo '
';
}
Result :
brad
josh
will
$peoples = array('brad'=>'brad@gmail.com','josh'=>'josh@gmail.com','will'=>'will@gmail.com');
foreach($peoples as $person => $email){
echo $person.' : '.$email;
echo '
';
}
Result :
brad : brad@gmail.com
josh : josh@gmail.com
will : will@gmail.com
Top
Go to Next
main