Learn one of the most powerful programming languages in the world and become a rockstar developer.
A string is a sequence of characters, like "Hello world!".
In PHP, the strlen()
function returns the length of a string.
<?php echo strlen("Hello world!"); //this gives output 12 ?>
In PHP, the str_word_count()
function returns the number of words in a string.
<?php echo str_word_count("Hello world!"); /this gives output 2 ?>
In PHP, the strrev()
function reverse a string.
<?php echo strrev("Hello world!"); // output : !dlrow olleH ?>
In PHP, the strpos()
function return a postion of letter or word in string. If not found then return FALSE
<?php echo strpos("Hello world!", "world"); //this give output 6 ?>
Tips: The first character position in a string is 0 (not 1).
In PHP, the str_replace()
function replace the string within a string
<?php echo str_replace("world", "Adzetech", "Hello world!"); //output is : Hello Adzetech! ?>