Created
November 7, 2017 12:56
-
-
Save omitobi/4960bf212c5286d727f299f4613eac55 to your computer and use it in GitHub Desktop.
String pad
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
| /** | |
| * @param string $string | |
| * @param string $pad | |
| * @param int $expected_length | |
| * @return string | |
| */ | |
| function str_pad($string, $pad, $expected_length) | |
| { | |
| $left = $expected_length - strlen($string); | |
| while ($left > 0) { | |
| $string = $pad.$string; | |
| $left --; | |
| } | |
| return $string; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment