<?php
$d = array(
array(
"id", "int(10) unsigned", "NO", "PRI", "auto_increment"
), array(
"title", "varchar(32)", "NO"
), array(
"author", "varchar(32)", "NO"
), array(
"category", "tinyint(3) unsigned", "NO"
), array(
"date", "datetime", "NO"
), array(
"post_ip", "int(10) unsigned", "NO"
), array(
"approved_by", "varchar(32)", "NO"
), array(
"text", "text", "NO"
)
);
$cols = array();
$rows = 0;
foreach ($d as $row) {
($rows < count($row) && $rows = count($row));
foreach($row as $id => $col) {
(!isset($cols[$id]) && $cols[$id] = 0);
($cols[$id] < strlen($col) && $cols[$id] = strlen($col));
}
}
foreach ($d as $row) {
$row = array_pad($row,$rows,'');
foreach ($row as $colid => &$col) $col = str_pad($col, $cols[$colid]);
$string = implode($row," # ") . "\n";
echo $string;
}
preferences:
40.93 ms | 402 KiB | 5 Q