经测试代码如下:
/**
* 给字符串前后添加指定数量的符号
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function str_prefix($str,$n=1,$char=" "){
for ($x=0;$x<$n;$x++){ $str = $char . $str; }
return $str;
}
function str_suffix($str,$char=" "){
for ($x=0;$x<$n;$x++){ $str = $str . $char; }
return $str;
}
//用法举例:
str_prefix('test',3,'-') => returns '---test'<br/>str_suffix('test','-') => returns 'test---'<br/>
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528911.html