Sunday, September 16, 2012

how to extract number of word in a string and string count using php

<?php
$str = "extract word from a sring using php";
//before
$extractword= str_word_count($str);
$extword=explode(" ",$str);
//count word from string
echo count($extword);
echo "total word in a string is =$extractword<br>";
// after
$couter=1;
foreach($extword as $word){
echo "$couter  ".$word."<br>";
$couter=$couter+1;


}
?>provided by amazon and ebay

No comments:

Post a Comment