PHP String functions

A

addcslashes()

The PHP addcslashes() function returns a string with backslashes before the characters that are listed in the characters parameter.

addslashes()

The PHP addslashes() function returns a string with backslashes before characters that need to be escaped.

E

explode()

The PHP explode() function splits a string into an array using a specified delimiter.

H

htmlentities()

The PHP htmlentities() function converts all applicable characters to HTML entities.

htmlspecialchars()

The PHP htmlspecialchars() function converts special characters to HTML entities.

I

implode()

The PHP implode() function joins array elements into a string using a specified separator.

L

lcfirst()

The PHP lcfirst() function makes the first character of a string lowercase.

ltrim()

The PHP ltrim() function removes whitespace or specified characters from the beginning of a string.

N

nl2br()

The PHP nl2br() function inserts HTML line breaks before all newlines in a string.

R

rtrim()

The PHP rtrim() function removes whitespace or specified characters from the end of a string.

S

str_contains()

The PHP str_contains() function checks if a string contains a given substring.

str_ends_with()

The PHP str_ends_with() function checks if a string ends with a given substring.

str_replace()

The PHP str_replace() function replaces all occurrences of a search string with a replacement string.

str_starts_with()

The PHP str_starts_with() function checks if a string starts with a given substring.

strcmp()

The PHP strcmp() function compares two strings in a case-sensitive manner.

strip_tags()

The PHP strip_tags() function removes HTML and PHP tags from a string.

strlen()

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

strncmp()

The PHP strncmp() function compares the first N characters of two strings.

strpos()

The PHP strpos() function is used to find the position of the first occurrence of a substring within a string.

strrpos()

The PHP strrpos() function finds the position of the last occurrence of a substring within a string.

strtolower()

The PHP strtolower() function converts a string to lowercase.

strtoupper()

The PHP strtoupper() function converts a string to uppercase.

substr()

The PHP substr() function returns a portion of a string.

T

trim()

The PHP trim() function removes whitespace (or other predefined characters) from the beginning and end of a string.

U

ucfirst()

The PHP ucfirst() function makes the first character of a string uppercase.

ucwords()

The PHP ucwords() function capitalizes the first character of each word in a string.

W

wordwrap()

The PHP wordwrap() function wraps a string to a given number of characters.