PHP String Functions

In this tutorial, you will learn about PHP string functions used for string manipulation.

PHP offers many built-in functions for string manipulation.

Function Description
addcslashes() Returns a string with backslashes before the specified characters in a given string.
addslashes() Returns a string with predefined characters preceded by a backslash.
bin2hex() Converts a string of ASCII characters to a hexadecimal value.
chop() Removes spaces or other predefined characters from the right end of a string.
chr() Returns a character from the specified ASCII value.
chunk_split() Splits a string into smaller sections and inserts a specific delimiter between each section.
convert_uudecode() Is used to decodes a uuencoded string.
convert_uudecode() Is used to uuencode a string.
count_chars() Returns information about the occurrences of characters in a string.
crc32() Is used to calculate a 32-bit cyclic redundancy check (CRC) checksum of a string.
crypt() Is used for one-way hashing of strings. Often used to store passwords securely.
echo() Use the echo function to output data.
explode() Split a string into an array of substrings based on a specified separator.
fprintf() It writes a formatted string to the specified output stream.
get_html_translation_table() Is used to return the conversion table used by htmlspecialchars() and htmlentities().
hex2bin() It converts a string of hexadecimal values ​​to ASCII characters.
html_entity_decode() It converts HTML entities to characters.
htmlentities() It converts characters to HTML entities.
htmlspecialchars_decode() It converts several predefined HTML entities to characters.
htmlspecialchars() It converts some predefined characters into HTML entities.
implode() Is used to returns a string consisting of the elements of the array.
join() Is used to returns a string consisting of the elements of the array.
lcfirst() Is used to converts the first character of a string to lowercase.
levenshtein() Is used to returns the Levenshtein distance between two strings.
ltrim() Is used to remove whitespaces from the beginning of a string