Function |
Function Details |
Example |
Output |
Strlen() |
It returns the length of a string. |
echo strlen("PHP Lang!"); |
9 |
Strrev() |
It reverses a string |
echo strrev("abcd 1234!"); |
!4321 dcba |
str_replace() |
Replace Text Within a String |
echo str_replace("Lang", "abcd","PHP world!"); |
PHP Lang! |
Ltrim() |
It is used to removes whitespace / other characters from the left side of a string. |
|
1234 |
Rtrim() |
It is used to removes whitespace or other characters from the right side of a string |
|
abcd |
trim() |
It is used to removes whitespace or other characters from both sides of a string |
|
P PHP LangP! PHP Lang |
Echo() |
It outputs 1 or more texts / strings. |
echo "PHP Lang! "; |
PHP Lang! |
str_repeat() |
It is used to repeat a string for a specified number of times. |
|
PHP PHP PHP PHP |
str_replace() |
It is used to replaces some characters in a string. |
|
In the string "PHP abcd!", the word "abcd!" is replaced with the word "Language!".
PHP Language!
|
str_word_count() |
It is used to Count the number of words in a string |
|
2 |
strcmp() |
It is used to Compares two strings and returns 0 if both are equal otherwise returns a non zero value. |
|
0 |
Strncmp() |
It is used to Compare two strings and returns 0 if both are equal otherwise returns a non zero value. With number of character positions. |
|
0 |
strripos() |
It is used to find the position of the last occurrence of a string inside other string. |
|
9 |
strtolower() |
It is used to convert a string to lowercase letters |
|
php language! |
strtoupper() |
It is used to convert a string to uppercase letters. |
|
PHP LANGUAGE! |
substr() |
It is used to returns a part of a string |
|
Language |
substr_replace () |
It is used to replaces a part of a string with other string |
|
PHP Language |