note 79832 deleted from function.sprintf by bjori
| From: | bjori@php.net | Date: | Fri, 14 Dec 2007 19:58:05 +0000 |
| Subject: | note 79832 deleted from function.sprintf by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133474@lists.php.net to get a copy of this message | ||
Note Submitter: eric humphrey
----
Function to create a nice separator for generated SQL scripts.
<?php
function separator( $tablename)
{
$maxLength = 80;
$strLength = strlen($tablename);
$rightPos = floor($maxLength / 2)
+ ($strLength - ceil($strLength / 2) - 1);
$rightPad = $maxLength - $rightPos;
/*echo "\$maxLength = $maxLength | ";
echo "\$strLength = $strLength | ";
echo "\$rightPos = $rightPos\n";*/
$rtnString = sprintf("%'-{$maxLength}s\n", "");
$rtnString .= sprintf("%'-{$rightPos}s", " {$tablename}")
. sprintf("%-'-{$rightPad}s\n", " ");
$rtnString .= sprintf("%'-{$maxLength}s\n", "");
return $rtnString;
}
?>
Example output (shortened because of posting restrictions):
--------------------------------------------------------------
------------------------- clients ----------------------------
--------------------------------------------------------------