str_repeat
Description
The str_repeat of String for PHP repeats a string.
Syntax
str_repeat(
string $string,
int $times
): stringParameters
string
The string to be repeated.
times
The number of times to be repeated.
times has to be greater than or equal to 0. If times is set to 0, the function will return an empty string.
Return
Returns the repeated string.
Examples
1 · string times · 0
<? $string = "Pete and Repeat were in a boat. Pete jumped out. Who was left?\n"; $times = 0; $return = str_repeat($string, $times); var_dump($return);
string(0) ""
2 · string times · 1
<? $string = "Pete and Repeat were in a boat. Pete jumped out. Who was left?\n"; $times = 1; $return = str_repeat($string, $times); echo $return;
Pete and Repeat were in a boat. Pete jumped out. Who was left?
3 · string times · 10
<? $string = "Pete and Repeat were in a boat. Pete jumped out. Who was left?\n"; $times = 10; $return = str_repeat($string, $times); echo $return;
Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left? Pete and Repeat were in a boat. Pete jumped out. Who was left?
Links
String
- addcslashes
- addslashes
- bin2hex
- chop
- chr
- chunk_split
- convert_uudecode
- convert_uuencode
- count_chars
- crc32
- crypt
- echo
- explode
- fprintf
- get_html_translation_table
- hebrev
- hebrevc
- hex2bin
- html_entity_decode
- htmlentities
- htmlspecialchars
- htmlspecialchars_decode
- implode
- join
- lcfirst
- levenshtein
- localeconv
- ltrim
- md5
- md5_file
- metaphone
- nl_langinfo
- nl2br
- number_format
- ord
- parse_str
- printf
- quoted_printable_decode
- quoted_printable_encode
- quotemeta
- rtrim
- setlocale
- sha1
- sha1_file
- similar_text
- soundex
- sprintf
- sscanf
- str_contains
- str_decrement
- str_ends_with
- str_getcsv
- str_increment
- str_ireplace
- str_pad
- str_replace
- str_rot13
- str_shuffle
- str_split
- str_starts_with
- str_word_count
- strcasecmp
- strchr
- strcmp
- strcoll
- strcspn
- strip_tags
- stripcslashes
- stripos
- stripslashes
- stristr
- strlen
- strnatcasecmp
- strnatcmp
- strncasecmp
- strncmp
- strpbrk
- strpos
- strrchr
- strrev
- strripos
- strrpos
- strspn
- strstr
- strtok
- strtolower
- strtoupper
- strtr
- substr
- substr_compare
- substr_count
- substr_replace
- trim
- ucfirst
- ucwords
- vfprintf
- vprintf
- vsprintf
- wordwrap