carloscarucce/mb-str-pad

Binary safe behavior for str_pad

v1.1 2022-06-01 13:43 UTC

This package is auto-updated.

Last update: 2024-10-30 01:48:15 UTC


README

Installing

composer require carloscarucce/mb-str-pad

Usage

include 'vendor/autoload.php';

$input = 'My text';
$length = 20;
$padding = ' '; // Optional. Default: ' '
$padType = STR_PAD_RIGHT; // Optional. Use STR_PAD_RIGHT, STR_PAD_LEFT or STR_PAD_BOTH. Default: STR_PAD_RIGHT   
$encoding = null; //Optional. Default: null

$result = mb_str_pad($input, $length, $padding, $padType, $encoding);
var_dump($result); // string(20) "My text             "

Run tests:

composer test