源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php str_pad 函数使用详解

  • 时间:2022-03-03 23:31 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php str_pad 函数使用详解
string str_pad ( string , int pad_length , string pad_string , int pad_type); string 指定字符串,pad_length指定长度,pad_string用来填充的字符串(可选参数),pad_type指定填充位置(可选参数,STR_PAD_LEFT,STR_PAD_BOTH); 如果pad_string , pad_type均为空,那么就等于默认pad_string 为空格, pad_type就是自动填充在指定字符串的末端.
[u]复制代码[/u] 代码如下:
<? $string = "test"; echo str_pad($string , 10); // produces "test "; ?>
其余两个例子:
[u]复制代码[/u] 代码如下:
<? $string = "test"; echo str_pad($string , 10,'+',STR_PAD_LEFT); // produces "++++++test"; ?>
[u]复制代码[/u] 代码如下:
<? $string = "test"; echo str_pad($string , 10,'+',STR_PAD_BOTH); // produces "+++test+++"; ?>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部