Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- element추가
- 시간계산
- 세션
- 웹프로그래밍
- ucfirst
- parent of iframe
- php
- input
- CSS
- 이전주소
- File
- indexOf
- disabled
- Selector
- mb_strimwidth
- 세션사용법
- 문자열포함여부
- mysql
- strtotime
- accept
- SubString
- date
- HTML
- 쿠키
- Javascript
- strpos
- Meta Tag
- JQuery
- attr
- date포맷
Archives
- Today
- Total
Heojju
[PHP] str_word_count() - 문자열 카운트 본문
▤ str_word_count : 문자열에 있는 단어의 수를 카운트
str_word_count( string, [return], [char])
인수 | 설명 |
string | 문자열 |
return | * 0 : 기본. 단어의 수 return * 1 : 단어 배열 return * 2 : 키 문자열 |
char | 단어로 간주되는 특수문자를 지정 |
<?php
echo str_word_count("Hello world!");
?>
출력 : 2
<?php
print_r(str_word_count("Hello world!",1));
?>
출력 : Array ( [0] => Hello [1] => world )
<?php
print_r(str_word_count("Hello world & good morning!",1));
print "<br>";
print_r(str_word_count("Hello world & good morning!",1,"&"));
?>
출력 :
Array ( [0] => Hello [1] => world [2] => good [3] => morning )
Array ( [0] => Hello [1] => world [2] => & [3] => good [4] => morning )
<?php
print_r(str_word_count("Hello world & good morning!", 2));
print "<br>";
print_r(str_word_count("Hello world & good morning!",2,"&"));
?>
출력 :
Array ( [0] => Hello [6] => world [14] => good [19] => morning )
Array ( [0] => Hello [6] => world [12] => & [14] => good [19] => morning )
'웹개발 > PHP' 카테고리의 다른 글
[PHP] explode 함수 - 문자열 나누기 / 문자열 분리 (0) | 2017.01.12 |
---|---|
[PHP] strpos() 문자열 포함 여부 확인 (0) | 2016.12.19 |
[PHP] 데이터 엑셀로 저장기능 (0) | 2016.12.09 |
[PHP] strtotime 함수 (0) | 2016.12.06 |
[PHP] strip_tags 를 이용한 태그 삭제 (0) | 2016.11.30 |