Skip to content

Commit 02804ef

Browse files
committed
iteration of associative array in view
1 parent fe0c4a4 commit 02804ef

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

index.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2-
$arrayLists = [
3-
'ram',
4-
'shyam',
5-
'rita',
6-
'gita'
2+
3+
4+
$persons = [
5+
'name' => 'Ram',
6+
'age' => 30,
7+
'address' => 'Kathmandu',
8+
'country' => 'Nepal'
79
];
810

911
require ('index.tpl.php');

index.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919

2020
<ul>
21-
<?php foreach($arrayLists as $list) :?>
22-
<li><?= $list; ?></li>
21+
<?php foreach($persons as $attr => $value) :?>
22+
<li><?= $attr.' :'. $value; ?></li>
2323
<?php endforeach; ?>
2424
</ul>
2525

0 commit comments

Comments
 (0)