Created
March 5, 2018 01:36
-
-
Save nhalstead/0e6462af816861b9a7be5f542a96abf3 to your computer and use it in GitHub Desktop.
Fit Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Fill the Gaps, Fit Text to a Length. | |
* | |
* @param Int Input of the Target Length | |
* @param String The Text to Extend with $char | |
* @param String The Char to use to fill the blanks. | |
*/ | |
function fitText($textLength, $text, $char = " "){ | |
$t = strlen($text); | |
$fillC = $textLength - $t; | |
$fill = str_repeat($char, $fillC); | |
return $text.$fill; | |
} | |
header('Content-Type: text/plain'); | |
echo "`".fitText(15, "192.168.1.1")."`"; | |
echo "\n"; | |
echo "`".fitText(15, "192.168.1.88")."`"; | |
echo "\n"; | |
echo "`".fitText(15, "192.168.1.255")."`"; | |
echo "\n"; | |
echo "`".fitText(15, "192.168.12.12")."`"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment