- Модуль: biconnector
- Путь к файлу: ~/bitrix/modules/biconnector/lib/prettyprinter.php
- Класс: BitrixBIConnectorPrettyPrinter
- Вызов: PrettyPrinter::printRowsArray
static function printRowsArray($rows)
{
if (!$rows)
{
echo "No rows.n";
}
elseif (count($rows) == 1)
{
$ll = [];
foreach ($rows[0] as $header => $value)
{
$ll[$header] = strlen($header);
}
$l = max($ll);
foreach ($rows[0] as $header => $value)
{
echo str_pad($header, $l, ' ') . ': ' . $value . "n";
}
}
else
{
$ll = [];
foreach ($rows[0] as $header => $value)
{
$ll[$header] = strlen($header);
}
foreach ($rows as $row)
{
foreach ($row as $header => $value)
{
$ll[$header] = max($ll[$header], strlen($value));
}
}
$lastRow = count($rows) - 1;
foreach ($rows as $i => $row)
{
if ($i == 0)
{
foreach ($row as $header => $value)
{
echo str_pad('+', $ll[$header] + 3, '-');
}
echo "+n";
foreach ($row as $header => $value)
{
echo str_pad('| ' . $header, $ll[$header] + 3, ' ');
}
echo "|n";
foreach ($row as $header => $value)
{
echo str_pad('+', $ll[$header] + 3, '-');
}
echo "+n";
}
foreach ($row as $header => $value)
{
echo str_pad('| ' . $value, $ll[$header] + 3, ' ');
}
echo "|n";
if ($i == $lastRow)
{
foreach ($row as $header => $value)
{
echo str_pad('+', $ll[$header] + 3, '-');
}
echo "+n";
}
}
}
echo "n";
}