普贤教程 › 包参考
strpad 包
字符串填充与重复(PHP str_pad / str_repeat / str_truncate)
strpad.px — 字符串填充与重复(PHP str_pad / str_repeat / str_truncate)
| 项 | 值 |
|---|---|
| 包名 | strpad |
| 版本 | 0.1.0 |
| 入口 | strpad.px |
| 分类 | 文本与中文处理 |
| 文件数 / 行数 | 1 / 77 |
安装与引入
bash
pxpkg init # 首次 pxpkg add strpad@0.1.0 pxpkg install
px
import strpad所属分类教程:文本与中文处理
公开接口
| 函数 | 参数 |
|---|---|
sp_pad | s, width, pad=" ", side="right" |
sp_pad_left | s, width, pad=" " |
sp_pad_right | s, width, pad=" " |
sp_pad_both | s, width, pad=" " |
sp_repeat | s, n |
sp_truncate | s, width, suffix="..." |
sp_limit | s, width |
sp_zeropad | n, width |
包内说明(源码头注释)
text
strpad.px — 字符串填充与重复(PHP str_pad / str_repeat / str_truncate) 依赖: 无 函数列表: sp_pad(s, width, pad=" ", side="right") → string # 填充到指定宽度 sp_pad_left(s, width, pad=" ") → string sp_pad_right(s, width, pad=" ") → string sp_pad_both(s, width, pad=" ") → string sp_repeat(s, n) → string # 重复 n 次 sp_truncate(s, width, suffix="...") → string # 截断到宽度+后缀 sp_limit(s, width) → string # 硬截断 sp_zeropad(n, width) → string # 数字零填充