str_pad — 使用另一个字符串填充字符串为指定长度

 

<?php

$str = 'hello world ';

echo str_pad($str,20,'·');

?>

 

结果:hello world ····

 

参数:

input

输入字符串。

pad_length

如果 pad_length 的值是负数,小于或者等于输入字符串的长度,不会发生任何填充,并会返回 input 。

pad_string

Note:

如果填充字符的长度不能被 pad_string 整除,那么 pad_string 可能会被缩短。

pad_type

可选的 pad_type 参数的可能值为 STR_PAD_RIGHTSTR_PAD_LEFTSTR_PAD_BOTH。如果没有指定 pad_type,则假定它是 STR_PAD_RIGHT

返回值:返回填充后的字符串

相关文章:

  • 2021-11-05
  • 2021-11-26
  • 2021-12-20
  • 2022-12-23
  • 2021-04-05
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
猜你喜欢
  • 2022-02-16
  • 2021-12-23
  • 2021-07-13
  • 2022-12-23
  • 2021-10-06
  • 2021-11-16
  • 2021-08-18
相关资源
相似解决方案