gugglegum / mb-str-pad
mb_str_pad() - multibyte implementation of str_pad() function
Installs: 2 691
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- ext-mbstring: *
This package is auto-updated.
Last update: 2024-11-16 23:28:55 UTC
README
This is true multibyte implementation of PHP's built-in string function str_pad()
which support UTF-8 both in $input
and in $pad_string
.
This function is implemented as a static method of MbString
class (not as a standalone function) because PHP doesn't doesn't support autoloading of functions on demand. You will not want to include it prior every usage.
Installation
Quite simple: composer require gugglegum/mb-str-pad
Usage
<?php require_once 'vendor/autoload.php'; use gugglegum\mb_str_pad\MbString; $input = 'Привет'; $pad_length = 20; $pad_string = '÷˟‾҈'; $pad_type = STR_PAD_BOTH; $encoding = 'UTF-8'; echo MbString::mb_str_pad($input, $pad_length, $pad_string, $pad_type, $encoding);
In all cases of using single-byte $input
and $pad_string
the result will be the same as of built-in str_pad()
function.