: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* cycle through arguments
public static function cycle() {
$return_val = $args[$counter % count($args)];
public static function plainTextTable($table, $maxColumnWidth = 60) {
if (count($table) === 0) {
for ($row = 0; $row < count($table); $row++) {
if (is_string($table[$row])) { //Special handling to show a sub-header/divider
for ($col = 0; $col < count($table[$row]); $col++) {
$table[$row][$col] = wordwrap(str_replace("\t", " ", $table[$row][$col]), $maxColumnWidth, "\n", true);
foreach (explode("\n", $table[$row][$col]) as $colText) {
if (!isset($colLengths[$col])) {
$colLengths[$col] = strlen($colText);
if ($len > $colLengths[$col]) {
$colLengths[$col] = $len;
$totalWidth = array_sum($colLengths) + (count($colLengths) * 3) + 1;
$hr = str_repeat('-', $totalWidth);
for ($row = 0; $row < count($table); $row++) {
if (is_string($table[$row])) { //Special handling to show a sub-header/divider
if ($row > 1) { $output .= $hr . "\n"; }
$output .= '| ' . str_pad($table[$row], $totalWidth - 4, ' ', STR_PAD_BOTH) . ' ' . "|\n";
for ($col = 0; $col < count($table[$row]); $col++) {
$height = substr_count($table[$row][$col], "\n");
if ($height > $colHeight) {
for ($colRow = 0; $colRow <= $colHeight; $colRow++) {
for ($col = 0; $col < count($table[$row]); $col++) {
$colRows = explode("\n", $table[$row][$col]);
$output .= '| ' . str_pad(isset($colRows[$colRow]) ? $colRows[$colRow] : '', $colLengths[$col], ' ', STR_PAD_RIGHT) . ' ';
return trim($output . (count($table) > 1 ? $hr : ''));