Thursday 11 February 2016

Five String Functions in PHP

Code:

<!DOCTYPE html>
<html>
<body>
<center>
<h1>Five String Functions in PHP</h1>
<?php
    $name="Lionel Messi";
    echo "<h4>";
    echo "String : ".$name;
    echo "<br/>Length of the string : ".strlen($name);
    echo "<br/>Number of words in the string : ".str_word_count($name);
    echo "<br/>Reverse of the string : ".strrev($name);
    echo "<br/>Character position of Messi : ".strpos($name,"Messi");
    echo "<br/>Replace string : ".str_replace("Lionel", "Leo", $name);
    echo "</h4>";
?>
</center>
</body>
</html>


Output:

 

No comments:

Post a Comment