Strings str_repeat
(PHP 4, PHP 5, PHP 7, PHP 8)
str_repeat — Repeat a string
설명
str_repeat(string $string
, int $times
): string
string
을 times
반복하여 반환합니다.
매개변수
string
- 반복할 문자열입니다.
times
string
문자열이 반복되어야 하는 횟수입니다.times
은 0보다 크거나 같아야 합니다.times
이 0으로 설정되면 함수는 빈 문자열을 반환합니다.
반환 값
반복되는 문자열을 반환합니다.
Examples
예제 #1 str_repeat() 예제
<?php
echo str_repeat("-=", 10);
?>
위의 예는 다음을 출력합니다.
-=-=-=-=-=-=-=-=-=-=
기타
- for
- str_pad() - 다른 문자열로 특정 길이로 문자열 채우기
- substr_count() - 부분 문자열 발생 횟수 계산