String function in php
To reverse a string
strrev- It is used to reverse a string.
<?php
echo strrev("Hello world!"); // outputs !dlrow olleH
?>
To search for a specific text in your string
strpos- it return the character position of the text if true else return false
<?php
echo strpos("Hello world!", "world"); // outputs 6
?>
To replace a text
str_replace- To replace a text.
<?php
echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
?>
0 Comment(s)