2011-01-19 51 views

回答

6

PHP提供了一個名爲substr_count功能纔是最重要的傳入子出現的量:

$count = substr_count($str, ' '); //2 

要檢索詞的數量,你會使用str_word_count

$count = str_word_count($str); //3 
0

我想只有2位在此示例中......

暗示如下:

$no = count(explode(" ",$str))-1; 

如果你WA NT的瞭解(在你的例子一樣3)字樣

0

PHP有一個函數調用substr_count()的數量,你可以使用它像這樣:

$name= "albert slevir inshten"; 

echo substr_count($name, ' '); 
相關問題