php str_repeat() function


  Translation results:

英[rɪˈpi:t] 美[rɪˈpit]

vt. Repeat; retell, recite

vi. Redo; repeat voting

n. Repeat; ( program) reenactment; repeated things

Third person singular: repeats Plural: repeats Present participle: repeating Past tense: repeated Past participle: repeated

php str_repeat() functionsyntax

How to use the str_repeat() function?

php The str_repeat() function is used to reuse the specified string. The syntax is str_repeat(string,repeat). This function repeats the string a specified number of times.

Function: Reuse the specified string

Syntax: str_repeat(string,repeat)

Parameters:

ParameterDescription
stringMust be repeated String
repeat is required. It specifies the number of repetitions of the string and must be greater than or equal to 0

##Description: str_repeat() function repeats the string a specified number of times

php str_repeat() functionexample

<?php
$i = "hello world!";
$j = str_repeat($i,3);//设置字符串重复的次数为3
echo $j;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

hello world!hello world!hello world!
<?php
$i = "Learn PHP to come to php.cn<br>";
$j = str_repeat($i,3);
print_r($j);
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Learn PHP to come to php.cn
Learn PHP to come to php.cn
Learn PHP to come to php.cn

Home

Videos

Q&A