Php str repeat
From w3cyberlearnings
Contents |
PHP function str_repeat
This function repeats a specific string for a number of times.
Syntax str_repeat
- String: string to repeat
- totalrepeat: total of time the string has to repeat.
str_repeat(string,totalrepeat)
Example 1
<?php echo str_repeat("x", 5); ?>
Output
xxxxx
Example 2
<?php $title = "Work hard will make you success!"; $body = "Every needs to find ways to make yourself free of poverty.<br/>" . "You need to work hard, extremely hard."; echo $title; echo '<br/>'; echo str_repeat('~', strlen($title)); echo '<br/>'; echo $body; ?>
Output
Work hard will make you success! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Every needs to find ways to make yourself free of poverty. You need to work hard, extremely hard.