<?php
class class_column
{
public $title;
public $extract_;
public $format_;
public function __construct($title, $extract_, $format_ = null)
{
if ($format_ == null) $format_ = function ($x) {return $x;};
$this->title = $title;
$this->extract_ = $extract_;
$this->format_ = $format_;
}
public function extract($row)
{
return call_user_func($this->extract_, $row);
// return $this->extract_($row);
}
public function format($value)
{
return call_user_func($this->format_, $value);
// return $this->format_($value);
}
}
class class_table
{
private $columns;
private $rows;
public function __construct($columns, $rows = [])
{
$this->columns = $columns;
$this->rows = [];
$this->fill($rows);
}
private function add($row)
{
array_push($this->rows, $row);
}
private function fill($rows)
{
array_map