Skip to content

Instantly share code, notes, and snippets.

@bluetechy
Forked from nebiros/mb_str_pad.php
Created October 23, 2018 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluetechy/b565f11dc59ccf5eb95b744e68444f8e to your computer and use it in GitHub Desktop.
Save bluetechy/b565f11dc59ccf5eb95b744e68444f8e to your computer and use it in GitHub Desktop.
mb_str_pad
<?php
/**
* mb_str_pad
*
* @param string $input
* @param int $pad_length
* @param string $pad_string
* @param int $pad_type
* @return string
* @author Kari "Haprog" Sderholm
*/
function mb_str_pad( $input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT)
{
$diff = strlen( $input ) - mb_strlen( $input );
return str_pad( $input, $pad_length + $diff, $pad_string, $pad_type );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment