PHP string function
strlen()
This PHP function use to calculate length of a string with include space.
<?php
echo strlen("Jawab Adda!"); // outputs 11
?>
str_word_count()
This PHP function is used to count the number of words in a string.
<?php
echo str_word_count("Jawab Adda!"); // outputs 2
?>
strrev()
This PHP function return reverses a string
<?php
echo strrev("Jawab Adda!"); // outputs !addA bawaJ
?>
strpos()
This PHP function use to searches for a specific text within a string.
If a text is found, the it will returns the character position of the first found text. If it will not found, it will return FALSE.
<?php
echo strpos("Jawab Adda!", "Adda"); // outputs 6
//or second example
echo strpos("Jawab Adda!", ".com"); // no outputs
?>
substr_count()
This PHP function use to count some specific word how many times come in a string.
<?php
echo substr_count("Jawab Adda is Adda where you can find any answer", "Adda"); // outputs 2
?>
str_replace()
This PHP function use to replaces some characters with some other characters in a string.
<?php
echo str_replace("Jawab", "Answer", "Jawab Adda!"); // outputs Answer Adda!
?>