https://github.com/alexsoft/leftpad
There just should be a leftpad function for PHP :smile:
https://github.com/alexsoft/leftpad
leftpad php
Last synced: about 1 year ago
JSON representation
There just should be a leftpad function for PHP :smile:
- Host: GitHub
- URL: https://github.com/alexsoft/leftpad
- Owner: alexsoft
- License: mit
- Created: 2016-03-24T11:41:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-05T22:10:53.000Z (over 1 year ago)
- Last Synced: 2025-04-23T22:54:36.787Z (about 1 year ago)
- Topics: leftpad, php
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Left Pad for PHP
[](https://packagist.org/packages/alexsoft/leftpad)
A whole package is just one file with a single function `\Alexsoft\Leftpad\leftpad(string $string, int $length, string $filler): string`
$string - your initial string
$length - final length of returned string
$filler - symbol with which initial string should be left padded
### 1. Install
```bash
composer require alexsoft/leftpad
```
### 2. Use it
```php
\Alexsoft\Leftpad\leftpad('foo', 5) // => " foo"
\Alexsoft\Leftpad\leftpad('1', 3, '0') // => "001"
```