Learn about PHP strings and how to work with them.
|
trim() Trim Whitespace |
The trim() function removes whitespace or characters specified by a parameter from both ends of a string. |
|---|---|
|
strpos() Find First Substring Index |
The strpos() function for strings returns the index of the first occurrence of the specified substring. If the specified substring is not found, it returns false. |
|
mb_strpos() Multibyte-Safe Alternative to strpos() |
The mb_strpos() function searches for the position of a substring in a string. Unlike strpos(), it is multibyte-safe and correctly handles UTF-8 encoded text, including Japanese, Korean, and Chinese characters. |
|
stripos() Find First Substring Index (Case-Insensitive) |
The stripos() function returns the index of the first occurrence of the specified substring within a string. Unlike strpos(), this function performs a case-insensitive search. If the substring is not found, it returns false. |
|
mb_stripos() Multibyte-Safe Alternative to stripos() |
The mb_stripos() function searches for the position of a substring in a string. Unlike stripos(), it is multibyte-safe and correctly handles UTF-8 encoded text, including Japanese, Korean, and Chinese characters. |
|
str_contains() Check if a String Contains a Substring |
The str_contains() function checks if a string contains a specific substring. It returns true if the substring is found, or false otherwise. This function is case-sensitive. |
|
substr() Slice Strings by Position and Length |
The substr() function returns part of a string starting at a specified position and length. Useful for slicing strings and extracting substrings. |
|
mb_substr() Multibyte-Safe Alternative to substr() |
The mb_substr() function slices a string starting from a specified position (offset) and for a specified length, returning the extracted substring while safely handling multibyte characters. |
|
ctype_digit() Check if Only Numeric Character(s) |
The ctype_digit() function checks whether a given string contains only numeric character(s) from 0 to 9. It returns true if every character in the string passed as an argument is a digit; otherwise, it returns false. |
|
explode() Convert a String to an Array |
The explode() function splits a string into an array based on a custom delimiter. |
|
str_split() Split String by Length |
The str_split() function splits a string into an array by a specified length. The elements of the returned array are substrings split to the specified length. |
|
str_replace() Replace Text in a String |
The str_replace() function replaces specific text within a string with new text. It also supports replacing multiple values at once using arrays. |