str_word_count
文字列で使用されている単語に関する情報を返します
str_word_count()
関数は、文字列内の単語の数を計算します。
文字列の単語数を計算します「私は上海を愛しています!」:
<?php echo str_word_count ( "私は上海が大好き!" ) ; ?>
自分で試してみてください
文字列に単語を含む配列を返します。
<?php print_r ( str_word_count ( "私はShanghaiが大好き!" 、 1 ) ) ; ?>
自分で試してみてください
キー名が文字列内の単語の位置であり、キー値が実際の単語である配列を返します。
<?php print_r ( str_word_count ( "私は上海!" 、 2 ) ) ; ?>
自分で試してみてください
CHARパラメーターを設定して設定しない:
<?php print_r ( str_word_count ( "私は上海&おはようが大好き!" 、 1 ) ) ; print_r ( str_word_count ( "私はShanghai&Good Morning!" 、 1 、 "&" ) ) ; ?>
自分で試してみてください
str_word_count ( string 、 return 、 char )
パラメーター | 説明する |
---|---|
弦 | 必須。チェックする文字列を指定します。 |
戻る |
オプション。 str_word_count()関数の返品値を指定します。 考えられる値:
|
char | オプション。単語と見なされる特殊文字を指定します。 |