All Functions
|
leftpad - Left Padding
This method adds padding characters to the beginning of a string until it reaches a certain lenght.
You can define the length of the string and the padding to be used.
Usage(s)
leftpad ( $subject , $length , $padding ) |
Returns the string $subject with length length padded with $padding characters |
Parameter(s)
$subject |
The string (or number) to be lengthened |
$length |
the length of the target string after adding padding |
$padding |
The string to be added to the subject as padding
Note: If the padding string is longer than one character, the length of the target string can become larger than $length |
Example(s)
Left Padding Example
leftpad(123,6,*)
Returns: ***123
leftpad(leftpadding is 1337,100,!)
Returns: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!leftpadding is 1337
|
Left padding with a string
leftpad(...puertorico,60, ai)
Returns the lyrics of the chorus of the song Puerto Rico by VAYA CON DIOS:
ai ai ai ai ai ai ai ai ai ai ai ai ai ai ai ai...puertorico
|
See also
truncate - truncate string length
replace - string replace
rightpad - Right Padding
|
|