substr_count - 하위 문자열 항목 수를 센다.
substr_count - 하위 문자열 항목 수를 센다.
설명 ¶
int substr_count ( string $haystack , string $needle [, int $offset= 0 [, int $length ]])
substr_count () 는needle문자열에서부분 문자열이 발생 하는 횟수를 반환 haystack합니다. needle대소 문자를 구분하므로주의하십시오 .
참고 :
이 함수는 중복 된 하위 문자열을 계산하지 않습니다. 아래 예제를 참조하십시오!
매개 변수 ¶
haystack
검색 할 문자열
needle
검색 할 하위 문자열
offset
카운팅을 시작할 위치 오프셋입니다. 오프셋이 음수이면 문자열 끝에서부터 계산이 시작됩니다.
length
하위 문자열을 검색 할 지정된 오프셋 뒤의 최대 길이입니다. 오프셋과 길이가 길이보다 큰 경우 경고를 출력합니다 haystack. 음수 길이는의 끝에서부터 계산됩니다 haystack.
반환 값 ¶
이 함수는 정수를 반환합니다 .
예 ¶
Example # 1 substr_count () 예제
<?php
$text = 'This is a test';
echo strlen($text); // 14
echo substr_count($text, 'is'); // 2
// the string is reduced to 's is a test', so it prints 1
echo substr_count($text, 'is', 3);
// the text is reduced to 's i', so it prints 0
echo substr_count($text, 'is', 3, 3);
// generates a warning because 5+10 > 14
echo substr_count($text, 'is', 5, 10);
// prints only 1, because it doesn't count overlapped substrings
$text2 = 'gcdgcdgcd';
echo substr_count($text2, 'gcdgcd');
?>
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4736 | jQuery | 8년 전 | 1558 | ||
| 4735 | jQuery | 8년 전 | 1746 | ||
| 4734 | jQuery | 8년 전 | 1735 | ||
| 4733 | jQuery | 8년 전 | 2032 | ||
| 4732 | jQuery | 8년 전 | 1955 | ||
| 4731 | jQuery | 8년 전 | 1459 | ||
| 4730 | jQuery | 8년 전 | 1915 | ||
| 4729 | PHP |
|
8년 전 | 6898 | |
| 4728 | jQuery | 8년 전 | 2561 | ||
| 4727 | jQuery | 8년 전 | 1610 | ||
| 4726 | jQuery | 8년 전 | 1689 | ||
| 4725 | jQuery | 8년 전 | 1833 | ||
| 4724 | jQuery | 8년 전 | 1310 | ||
| 4723 | jQuery | 8년 전 | 1861 | ||
| 4722 | jQuery | 8년 전 | 1624 | ||
| 4721 | jQuery | 8년 전 | 1917 | ||
| 4720 | jQuery | 8년 전 | 1974 | ||
| 4719 | jQuery | 8년 전 | 1601 | ||
| 4718 | jQuery | 8년 전 | 1607 | ||
| 4717 | jQuery | 8년 전 | 1558 | ||
| 4716 | jQuery | 8년 전 | 1235 | ||
| 4715 | jQuery | 8년 전 | 1391 | ||
| 4714 | jQuery | 8년 전 | 1414 | ||
| 4713 | jQuery | 8년 전 | 1333 | ||
| 4712 | jQuery | 8년 전 | 2226 | ||
| 4711 | jQuery | 8년 전 | 1708 | ||
| 4710 | PHP |
|
8년 전 | 3747 | |
| 4709 | jQuery | 8년 전 | 1629 | ||
| 4708 | jQuery | 8년 전 | 1906 | ||
| 4707 | jQuery | 8년 전 | 1759 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기