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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4766 | jQuery | 8년 전 | 1679 | ||
| 4765 | jQuery | 8년 전 | 1351 | ||
| 4764 | jQuery | 8년 전 | 2168 | ||
| 4763 | jQuery | 8년 전 | 1856 | ||
| 4762 | jQuery | 8년 전 | 1634 | ||
| 4761 | jQuery | 8년 전 | 1936 | ||
| 4760 | jQuery | 8년 전 | 1301 | ||
| 4759 | jQuery | 8년 전 | 1599 | ||
| 4758 | jQuery | 8년 전 | 1315 | ||
| 4757 | jQuery | 8년 전 | 1280 | ||
| 4756 | jQuery | 8년 전 | 1498 | ||
| 4755 | jQuery | 8년 전 | 1651 | ||
| 4754 | jQuery | 8년 전 | 1616 | ||
| 4753 | jQuery | 8년 전 | 1772 | ||
| 4752 | jQuery | 8년 전 | 1522 | ||
| 4751 | jQuery | 8년 전 | 1842 | ||
| 4750 | jQuery | 8년 전 | 1982 | ||
| 4749 | jQuery | 8년 전 | 1442 | ||
| 4748 | PHP | 8년 전 | 2811 | ||
| 4747 | jQuery | 8년 전 | 1393 | ||
| 4746 | jQuery | 8년 전 | 1650 | ||
| 4745 | jQuery | 8년 전 | 1658 | ||
| 4744 | jQuery | 8년 전 | 1537 | ||
| 4743 | jQuery | 8년 전 | 1614 | ||
| 4742 | jQuery | 8년 전 | 1708 | ||
| 4741 | jQuery | 8년 전 | 1600 | ||
| 4740 | jQuery | 8년 전 | 1610 | ||
| 4739 | jQuery | 8년 전 | 1798 | ||
| 4738 | jQuery | 8년 전 | 1316 | ||
| 4737 | jQuery | 8년 전 | 2102 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기