Advertisement
XeroXer

akrabat.com - after

Mar 14th, 2011
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement