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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4706 | jQuery | 8년 전 | 1514 | ||
| 4705 | jQuery | 8년 전 | 2169 | ||
| 4704 | jQuery | 8년 전 | 1704 | ||
| 4703 | jQuery | 8년 전 | 2041 | ||
| 4702 | jQuery | 8년 전 | 1830 | ||
| 4701 | jQuery | 8년 전 | 2062 | ||
| 4700 | jQuery | 8년 전 | 1741 | ||
| 4699 | jQuery | 8년 전 | 1528 | ||
| 4698 | jQuery | 8년 전 | 1337 | ||
| 4697 | jQuery | 8년 전 | 1753 | ||
| 4696 | jQuery | 8년 전 | 2372 | ||
| 4695 | jQuery | 8년 전 | 1388 | ||
| 4694 | jQuery | 8년 전 | 1796 | ||
| 4693 | jQuery | 8년 전 | 1775 | ||
| 4692 | jQuery | 8년 전 | 2566 | ||
| 4691 | jQuery | 8년 전 | 2071 | ||
| 4690 | jQuery | 8년 전 | 1964 | ||
| 4689 | jQuery | 8년 전 | 1941 | ||
| 4688 | jQuery | 8년 전 | 1702 | ||
| 4687 | jQuery | 8년 전 | 1118 | ||
| 4686 | jQuery | 8년 전 | 1749 | ||
| 4685 | jQuery | 8년 전 | 2492 | ||
| 4684 | jQuery | 8년 전 | 2372 | ||
| 4683 | jQuery | 8년 전 | 1763 | ||
| 4682 | PHP | 8년 전 | 3086 | ||
| 4681 | jQuery | 8년 전 | 1608 | ||
| 4680 | jQuery | 8년 전 | 1790 | ||
| 4679 | PHP | 8년 전 | 2020 | ||
| 4678 | PHP | 8년 전 | 2150 | ||
| 4677 | PHP | 8년 전 | 2257 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기