-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharray-func.php
More file actions
34 lines (27 loc) · 885 Bytes
/
array-func.php
File metadata and controls
34 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Topic: Loop
* Author: Muhammad Afzal
* Class: e-Rozgaar Batch#11
* Date: 7th Jan 2021
*/
//Define Constant
define("BR","<br />");
$name=array("Afzal","Faisal","Kashif","Kamran");
if(is_array($name)){ //Verify if it's Array or Not?
if(count($name)>0){ //Count the Total Length of Array
for($a=0;$a<count($name);$a++){
echo $name[$a].BR;
}
}
}
$cars = array (
"Volvo"=>array("Brand"=>"Volvo","InStock"=>22,"SoldOut"=>18),
"BMW"=>array("Brand"=>"BMW","InStock"=>15,"SoldOut"=>13),
"Saab"=>array("Brand"=>"Saab","InStock"=>5,"SoldOut"=>2),
"LandRover"=>array("Brand"=>"Land Rover","InStock"=>17,"SoldOut"=>15)
);
//Print the Whole Array
echo "<pre>";
print_r($cars);
echo "</pre>";