PHP chunk_split() 함수
예시
각 문자 뒤에 문자열을 분할하고 "."를 추가합니다. 각 분할 후:
<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>
정의 및 사용
chunk_split() 함수는 문자열을 일련의 더 작은 부분으로 분할합니다.
참고: 이 함수는 원래 문자열을 변경하지 않습니다.
통사론
chunk_split(string,length,end)
매개변수 값
Parameter | Description |
---|---|
string | Required. Specifies the string to split |
length | Optional. A number that defines the length of the chunks. Default is 76 |
end | Optional. A string that defines what to place at the end of each chunk. Default is \r\n |
기술적 세부 사항
반환 값: | 분할 문자열을 반환합니다. |
---|---|
PHP 버전: | 4+ |
더 많은 예
예시
각 6번째 문자 뒤에 문자열을 분할하고 각 분할 뒤에 "..."를 추가합니다.
<?php
$str = "Hello world!";
echo chunk_split($str,6,"...");
?>
❮ PHP 문자열 참조