fork download
  1. <?php
  2.  
  3. function mb_str_pad( $input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding="UTF-8") {
  4. $diff = strlen( $input ) - mb_strlen($input, $encoding);
  5. return str_pad( $input, $pad_length + $diff, $pad_string, $pad_type );
  6. }
  7.  
  8. echo mb_str_pad("ddã", 10, "0", STR_PAD_LEFT) . "\n";
  9. echo str_pad("ddã", 10, "0", STR_PAD_LEFT);
  10.  
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
0000000ddã
000000ddã