-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoDimensionalWithAssociativeArray.php
More file actions
36 lines (31 loc) · 1.1 KB
/
TwoDimensionalWithAssociativeArray.php
File metadata and controls
36 lines (31 loc) · 1.1 KB
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
35
36
<?php
$colleges=array(
"shreeyantra"=>array("college"=>"Damak Technical","program"=>"BIM,BSCCSIT","address"=>"Damak-9"),
"DMC"=>array("college"=>"Damak multiple","program"=>"BBA,BCA","address"=>"Damak-8")
);
echo $colleges["DMC"]["college"];
echo "<br>";
echo $colleges["shreeyantra"]["program"];
echo "<br>";
echo $colleges["shreeyantra"]["college"]." is situated in ".$colleges["shreeyantra"]["address"]." and offers programs like: ".$colleges["shreeyantra"]["program"]."<br><br>";
//another program
$grades=array(
"ram"=>array("c-program"=>"A","web-technology"=>"A-","java"=>"A"),
"sita"=>array("c-program"=>"B+","web-technology"=>"A","java"=>"A-")
);
//Accessing individual grades
echo $grades["sita"]["web-technology"]."<br>";
//Accessing overall grades...simple way
foreach ($grades as $grade) {
echo $grade["c-program"].",".$grade["web-technology"].",".$grade["java"]."<br>";
}
echo "<br>";
//standard way
foreach ($grades as $student => $subjects) {
echo "Grades for $student:"."<br>";
foreach ($subjects as $subject => $grade) {
echo "$subject: $grade"."<br>";
}
echo "<br><br>";
}
?>