campo-sirio/corsi/admin/cestino/classe_old.php

55 lines
734 B
PHP
Raw Normal View History

<html>
<head></head>
<body>
<?php
class Table
{
var $table_array = array();
var $headers = array();
var $cols;
function table($headers)
{
$this->headers = $headers;
$this->cols = count($headers);
}
function addrow($row)
{
if (count($row) != $this->cols)
return false;
array_push($this->table_array, $row);
return true;
}
function output()
{
print "<pre>";
foreach($this->headers as $headers)
print "<b>$headers</b>";
print "\n";
foreach($this->table_array as $y)
{
foreach($y as $xcell)
print "$xcell";
print "\n";
}
print "</pre>";
}
}
$test = new table(array("a","b","c"));
$test->addrow(array(1,2,3));
$test->addrow(array(4,5,6));
$test->output();
?>
</body>
</html>