<?php
class align {
function align($verbose = 0) {
$this->verbose = $verbose;
/* if ($this->verbose == 2) {
echo $this->left('VERBOSE',0).": Extra Verbose\n";
} elseif ($this->verbose == 1) {
echo $this->left('VERBOSE',0).": Verbose\n";
} else {
echo $this->left('VERBOSE',0).": Not Verbose\n";
}*/
}
function align_d_echo($name, $dvar='') {
if ($name == "*") {
$name = "******************";
}
if ($this->verbose >= 2) { echo $this->left($name, 0).": ".$dvar."\n"; }
}
function align_d_echo_a($darr) {
if ($this->verbose >= 2) {
echo $this->left("******************",0).": Array\n";
foreach ($darr as $key => $value) {
echo $this->left($key, 0).": ".$value."\n";
}
echo $this->left("******************",0).": End Array\n";
}
}
function align_v_echo($name, $dvar='') {
if ($name == "*") {
$name = "******************";
}
if ($this->verbose >= 1) { echo $this->left($name, 0).": ".$dvar."\n"; }
}
function align_v_echo_a($darr) {
if ($this->verbose >= 1) {
echo $this->left("******************",0).": Array\n";
foreach ($darr as $key => $value) {
echo $this->left($key, 0).": ".$value."\n";
}
echo $this->left("******************",0).": End Array\n";
}
}
function align_s_echo($name, $dvar='') {
if ($name == "*") {
$name = "******************";
}
echo $this->left($name, 0).": ".$dvar."\n";
}
function align_s_echo_a($darr) {
echo $this->left("******************",0).": Array\n";
foreach ($darr as $key => $value) {
echo $this->left($key, 0).": ".$value."\n";
}
echo $this->left("******************",0).": End Array\n";
}
function center($string, $length=0) {
if ($length == 0) { $length = 20; }
$str_len = strlen($string);
$half = ($length - $str_len) / 2;
$front_string = "";
$end_string = "";
$diff_string = "";
for ($i = 1; $i <= $half; $i++) { $front_string = $front_string." "; }
for ($i = 1; $i <= $half; $i++) { $end_string = $end_string." "; }
$complete_string = $front_string.$string.$end_string;
$complete_len = strlen($complete_string);
if ($complete_len != $length) {
$diff = $length - $complete_len;
for ($i = 1; $i <= $diff; $i++) { $diff_string = $diff_string." "; }
$complete_string = $diff_string.$complete_string;
}
return $complete_string;
}
function right($string, $length=0) {
if ($length == 0) { $length = 20; }
$str_len = strlen($string);
$front_len = $length - $str_len;
$front_string = "";
$diff_string = "";
for ($i = 1; $i <= $front_len; $i++) { $front_string = $front_string." "; }
$complete_string = $front_string.$string;
$complete_len = strlen($complete_string);
if ($complete_len != $length) {
$diff = $length - $complete_len;
for ($i = 1; $i <= $diff; $i++) { $diff_string = $diff_string." "; }
$complete_string = $diff_string.$complete_string;
}
return $complete_string;
}
function left($string, $length=0) {
if ($length == 0) { $length = 20; }
$str_len = strlen($string);
$end_len = $length - $str_len;
$end_string = "";
$diff_string = "";
for ($i = 1; $i <= $end_len; $i++) { $end_string = $end_string." "; }
$complete_string = $string.$end_string;
$complete_len = strlen($complete_string);
if ($complete_len != $length) {
$diff = $length - $complete_len;
for ($i = 1; $i <= $diff; $i++) { $diff_string = $diff_string." "; }
$complete_string = $diff_string.$complete_string;
}
return $complete_string;
}
}
?>