View difference between Paste ID: ycYfVx7g and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | <?php |
2 | ||
3 | class App_View_Helper_Tabulate extends Zend_View_Helper_Abstract | |
4 | { | |
5 | public function tabulate ($data, $attribs = array()) | |
6 | { | |
7 | $attribString = ''; | |
8 | foreach ($attribs as $key => $value) { | |
9 | $attribString .= ' ' . $key .'="' . $value . '"'; | |
10 | } | |
11 | ||
12 | $header = array_shift($data); | |
13 | $html = "<table $attribString>\n<tr>\n"; | |
14 | foreach ($header as $cell) { | |
15 | $escapedCell = $this->view->escape($cell); | |
16 | $html .= "<th>$escapedCell</th>\n"; | |
17 | } | |
18 | $html .= "</tr>\n"; | |
19 | foreach ($data as $row) { | |
20 | $html .= "<tr>\n"; | |
21 | foreach ($row as $cell) { | |
22 | $escapedCell = $this->view->escape($cell); | |
23 | $html .= "<td>$escapedCell</td>\n"; | |
24 | } | |
25 | $html .= "</tr>\n"; | |
26 | } | |
27 | ||
28 | $html .= '</table>'; | |
29 | return $html; | |
30 | } | |
31 | } |