-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_table.class.php
More file actions
36 lines (36 loc) · 856 Bytes
/
my_table.class.php
File metadata and controls
36 lines (36 loc) · 856 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
35
36
<?php
class MyTable{
function display($myarray, $head = False){
if ($head == True){
$len = count($myarray[0]);
$akeys = array_keys($myarray);
echo '<tr><thead>';
foreach($akeys as $head){
echo '<th>'.$head.'</th>';
}
echo '</thead></tr>';
$cur = "0";
foreach($myarray as $element){
$tmparray = array();
foreach($myarray as $innerarray){
array_push($tmparray, $innerarray[$cur]);
}
echo '<tr>';
foreach($tmparray as $key){
echo '<td>'.$key.'</td>';
}
echo '</tr>';
$cur+="1";
}
}
else{
foreach($myarray as $element){
echo '<tr>';
foreach($element as $key){
echo '<td>'.$key.'</td>';
}
echo '</tr>';
}
}
}
}