PHP String str_repeat()函數
str_repeat()是PHP的預定義函數。愛掏網 - it200.com它用于重復一個字符串指定的次數。愛掏網 - it200.com它返回重復多次的輸入。愛掏網 - it200.com
tr_repeat(string,repeat);
參數 | 描述 | 必需/可選 |
---|---|---|
string | 指定要重復的字符串 | 必需 |
repeat | 指定重復的次數 | 必需 |
示例1
<?php
echo "Before using 'str_repeat()' function: ('.',13)";
echo "<br>";
echo "After using 'str_repeat()' function:".str_repeat(".",13);
?>
輸出:
Before using 'str_repeat()' function: ('.',13)
After using 'str_repeat()' function:..............
示例2
<?php
echo "Before using 'str_repeat()' function: ('-=',10)";
echo "<br>";
echo "After using 'str_repeat()' function:".str_repeat('-=',10);
?>
輸出:
Before using 'str_repeat()' function: ('-=',10)
After using 'str_repeat()' function:-=-=-=-=-=-=-=-=-=-=
示例3
<?php
echo "Before using 'str_repeat()' function: ('?,10)";
echo "<br>";
echo "After using 'str_repeat()' function:".str_repeat('?',10);
?>
輸出:
Before using 'str_repeat()' function: (' ??,10)
After using 'str_repeat()' function: ? ? ? ? ? ? ? ? ? ?;
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。