str_word_count

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

str_word_count锟斤拷锟斤拷锟街凤拷锟斤拷锟叫碉拷锟绞碉拷使锟斤拷锟斤拷锟�

说锟斤拷

str_word_count ( string $string [, int $format = 0 [, string $charlist ]] ) : mixed

统锟斤拷 string 锟叫碉拷锟绞碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟窖★拷牟锟斤拷锟� format 没锟叫憋拷指锟斤拷锟斤拷锟斤拷么锟斤拷锟斤拷值锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街革拷锟斤拷锟� format 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷一锟斤拷锟斤拷锟介,锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟饺★拷锟斤拷锟� format 锟斤拷锟斤拷锟斤拷format 锟侥匡拷锟斤拷值锟斤拷锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫★拷

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥匡拷锟斤拷锟剿碉拷锟斤拷锟斤拷实亩锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟截碉拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷锟斤拷园锟斤拷锟斤拷锟侥革拷址锟斤拷锟揭诧拷锟斤拷园锟斤拷锟� "'" 锟斤拷 "-" 锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷始锟斤拷锟斤拷

锟斤拷锟斤拷

string

锟街凤拷锟斤拷锟斤拷

format

指锟斤拷锟斤拷锟斤拷锟侥凤拷锟斤拷值锟斤拷锟斤拷前支锟街碉拷值锟斤拷锟铰o拷

  • 0 - 锟斤拷锟截碉拷锟斤拷锟斤拷锟斤拷
  • 1 - 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷 string 锟斤拷全锟斤拷锟斤拷锟绞碉拷锟斤拷锟斤拷
  • 2 - 锟斤拷锟截癸拷锟斤拷锟斤拷锟介。锟斤拷锟斤拷募锟斤拷堑锟斤拷锟斤拷锟� string 锟叫筹拷锟街碉拷锟斤拷值位锟矫o拷锟斤拷锟斤拷锟街碉拷锟斤拷锟斤拷锟斤拷锟斤拷

charlist

锟斤拷锟接碉拷锟街凤拷锟斤拷锟叫憋拷锟斤拷锟叫碉拷锟街凤拷锟斤拷锟斤拷锟斤拷为锟斤拷锟绞碉拷一锟斤拷锟街★拷

锟斤拷锟斤拷值

锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟饺★拷锟斤拷锟� format 锟斤拷锟斤拷锟斤拷选锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.1.0 锟斤拷锟斤拷 charlist 锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷

Example #1 str_word_count() 锟斤拷锟斤拷

<?php

$str 
"Hello fri3nd, you're
       looking          good today!"
;

print_r(str_word_count($str1));
print_r(str_word_count($str2));
print_r(str_word_count($str1'锟斤拷锟斤拷??3'));

echo 
str_word_count($str);

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Array
(
    [0] => Hello
    [1] => fri
    [2] => nd
    [3] => you're
    [4] => looking
    [5] => good
    [6] => today
)

Array
(
    [0] => Hello
    [6] => fri
    [10] => nd
    [14] => you're
    [29] => looking
    [46] => good
    [51] => today
)

Array
(
    [0] => Hello
    [1] => fri3nd
    [2] => you're
    [3] => looking
    [4] => good
    [5] => today
)

7

锟轿硷拷

  • explode() - 使锟斤拷一锟斤拷锟街凤拷锟斤拷锟街革拷锟斤拷一锟斤拷锟街凤拷锟斤拷
  • preg_split() - 通锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷式锟街革拷锟街凤拷锟斤拷
  • split() - 锟斤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟街凤拷锟斤拷锟街割到锟斤拷锟斤拷锟斤拷
  • count_chars() - 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷息
  • substr_count() - 锟斤拷锟斤拷锟街达拷锟斤拷锟街的达拷锟斤拷