Here we will look on some of the function of strings:

strlen() :To get the length of the string.example:

<?php
$t="hello";
echo strlen($t);
?>
Result:
5

 str_word_count : count the number of words

<?php
echo str_word_count("Hello world!"); 
?>

  Result: 

2

strrev(): It is used to reverse the string


<?php
echo strrev("Good Morning!"); 
?>

  Output: 

!gninroM dooG

strpos() : Search for specific text with in a string:

<?php
echo strpos("Hello world!", "r");
?>
Output:
8

 str_replace:Replace one character from other character.

<?php
echo str_replace("Morning" , "afternoon","Good Morning");
?>

  Output: 

Good afternoon


  Modified On Mar-15-2018 05:48:33 AM

Leave Comment