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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4796 | jQuery | 8년 전 | 1544 | ||
| 4795 | jQuery | 8년 전 | 1445 | ||
| 4794 | jQuery | 8년 전 | 1569 | ||
| 4793 | jQuery | 8년 전 | 1622 | ||
| 4792 | jQuery | 8년 전 | 1638 | ||
| 4791 | jQuery | 8년 전 | 1798 | ||
| 4790 | jQuery | 8년 전 | 1737 | ||
| 4789 | jQuery | 8년 전 | 1600 | ||
| 4788 | jQuery | 8년 전 | 1662 | ||
| 4787 | jQuery | 8년 전 | 1476 | ||
| 4786 | jQuery | 8년 전 | 1437 | ||
| 4785 | jQuery | 8년 전 | 1648 | ||
| 4784 | jQuery | 8년 전 | 1533 | ||
| 4783 | jQuery | 8년 전 | 1239 | ||
| 4782 | jQuery | 8년 전 | 1605 | ||
| 4781 | jQuery | 8년 전 | 1345 | ||
| 4780 | jQuery | 8년 전 | 1579 | ||
| 4779 | jQuery | 8년 전 | 1988 | ||
| 4778 | jQuery | 8년 전 | 1963 | ||
| 4777 | jQuery | 8년 전 | 1537 | ||
| 4776 | jQuery | 8년 전 | 1589 | ||
| 4775 | jQuery | 8년 전 | 1976 | ||
| 4774 | jQuery | 8년 전 | 1492 | ||
| 4773 | jQuery | 8년 전 | 1417 | ||
| 4772 | jQuery | 8년 전 | 2208 | ||
| 4771 | jQuery | 8년 전 | 3623 | ||
| 4770 | PHP | 8년 전 | 5587 | ||
| 4769 | 기타 | 8년 전 | 1969 | ||
| 4768 | 기타 | 8년 전 | 1787 | ||
| 4767 | 기타 | 8년 전 | 2074 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기