PHP Strings


A String is sequence of character like “Hello Microtech!!”.


PHP String Functions

In this chapter we will look at some commonly used functions to manipulate strings.


Get The Length of a String

The PHP strlen() function returns length of a string (number of character)


Count Number of word in a string

The PHP str_word_count() function counts number of words in a string.


Reverse a String

The strrev() function reverse a string.

Search for Specific text within a string

The PHP strpos() function search for specific text within a string.

Replace Text Within a String

The PHP str_replace() function replaces some characters with some other characters in a string.


[sam id=”4″ codes=”true”]


[message_box color=”yellow”]


echo strlen(“Hello Microtech!”);
echo “<br>”;
echo strrev(“Hello Microtech!”);
echo “<br>”;
echo str_word_count(“Hello Microtech!”);
echo “<br>”;
echo strpos(“Hello Microtech!”, “Microtech”);
echo “<br>”;
echo str_replace(“Microtech”, “Engineers”, “Hello Microtech!”);






Leave a Reply

Please Login to comment
Notify of