More String Functions in PHP

More String Functions in PHP
Rating: 5 - 1 Votes

More String Functions in PHP

phpAs you know by now, string functions are very useful in manipulating a string.  The list of predefined string functions is huge, so we will discuss only mostly commonly used string functions.

Strlen:  This string function will return length of a string.

Ucfirst:  This string function will change case of first letter of the string to upper.

Ucwords:  This string function will change case of the first letter of every word in the string to upper.

Trim:  This string function will remove whitespaces or any predefined characters from both ends of a string.

Strstr:  This string function will search for an input string in a given string and if input string is found, it will return rest of the string followed by input string.

Str_repeat:  This string function will repeat a given string.  It will take a string and integer value as parameter. Integer value represents how many times you want to repeat that string.

Substr:  This string function will return a sub string in a given string.  It will take as parameters a string, integer value as start of index, and another integer value as number of characters to return.

Strpos:  This string function will return index position of input string in a given string.

Strchr:  This string function is pretty much similar to strstr.  This will return an entire string followed by a specific character.

Str_replace:  This string function will replace an input string in a given string.