1) Str_word_count():-
This function can return the number of works exists in the string
< ? php
$string1=”Harshida D Parmar ”;
$string2= Str_word_count($string1);
echo $string2;
// Example number 2
$string1=”Harshida D Parmar ”;
$string2= Str_word_count($string1,1);
Print_r( $string2);
// Example number 3
$string1=”Harshida D Parmar ”;
$string2= Str_word_count($string1,2);
Print_r( $string2);
?>
Here in the example number 2 , you can see that I have specify the second argument as a 1.
So this will return the ARRAY, Where the INDEX start with 0 ,1,2, and so on…
Position 0 show the 1st first , Position 1 show 2nd word, Position 2 shows 3rd word and so on…
Here in the example number 3 , you can see that I have specify the second argument as a 2.
So This will also return the ARRAY, Where the Index starting based on the FIRST CHARCTER POSTION Like [0] because Harshida, [7] D, [8] Parmar … So you can see that “H” start from 0, “D” Start from 7 And “8” P start from 8th position…
No comments:
Post a Comment