PHP String Handling

PHP String

A string is a sequence of characters, like “Hello PHP!”.

Run : http://ideone.com/vAUlM5

PHP String Functions

Get The Length of a String using strlen() Function

The PHP strlen() function returns the length of a string.

Run : http://ideone.com/GXnHx2

Count The Number of Words in a String using word_count() Function

Run : http://ideone.com/afYdZy

Reverse a String using strrev() Function

The PHP strrev() function reverses a string:

Run : http://ideone.com/E3puUo

Search For a Specific Text Within a String using strpos() Function

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

If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.

Run : http://ideone.com/daQuxN

Replace Text Within a String using str_replace() Function

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

Run : http://ideone.com/AFs0DW

Converts String into Uppercase using strtoupper() Function

This String function converts all letters of String into Uppercase.

Run : http://ideone.com/Obs3B2

Converts String into Lowercase using strtolower() function

This String function converts all letters of String into Uppercase.

Run : http://ideone.com/kITJOT

Capitalize the first letter of each word using ucwords() Function

This function is used to capitalized the first letter of each word in String.

Run : http://ideone.com/83vvyF

Remove the Whitespace using trim() Function

This function is only remove the whitespace at start and and end of the String.

Run : http://ideone.com/W0gD3v