欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php str_pad 函數(shù)使用詳解

 更新時(shí)間:2009年01月13日 23:55:32   作者:  
今天一朋友問(wèn)我str_pad()的使用方法.他說(shuō)網(wǎng)上很多都是直接把手冊(cè)上的拿過(guò)來(lái).于是我來(lái)寫(xiě)詳細(xì)點(diǎn). str_pad()函數(shù)的作用是:用一個(gè)字符串填充另一個(gè)指定字符串到指定長(zhǎng)度。
string str_pad ( string , int pad_length , string pad_string , int pad_type);
string 指定字符串,pad_length指定長(zhǎng)度,pad_string用來(lái)填充的字符串(可選參數(shù)),pad_type指定填充位置(可選參數(shù),STR_PAD_LEFT,STR_PAD_BOTH);
如果pad_string , pad_type均為空,那么就等于默認(rèn)pad_string 為空格, pad_type就是自動(dòng)填充在指定字符串的末端.
復(fù)制代碼 代碼如下:

<?
$string = "test";
echo str_pad($string , 10); // produces "test ";
?>

其余兩個(gè)例子:
復(fù)制代碼 代碼如下:

<?
$string = "test";
echo str_pad($string , 10,'+',STR_PAD_LEFT); // produces "++++++test";
?>

復(fù)制代碼 代碼如下:

<?
$string = "test";
echo str_pad($string , 10,'+',STR_PAD_BOTH); // produces "+++test+++";
?>

相關(guān)文章

最新評(píng)論