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 ( function ($row) {$this->add($row);}, $rows ); } public function generate() { ?>
title); ?> | columns ); ?>
---|
format($column->extract($row))); ?> | columns ); ?>