PHP String Functions

PHP String Functions

The PHP String Functions allow you to manipulate and access Strings. PHP supports a lot of inbuilt functions which are very helpful. These functions are a part of PHP core and there is no need to install them separately.

Articles

PHP addslashes is an inbuilt function in PHP. It escapes a string after adding backslashes in front of pre-defined characters. Also, it does not take any specified character as input. You can un-quote a string using the PHP stripslashes Function. The pre-defined character are: Single Quote (').Double Quotes (")Backslash (\)NULL ...
Read More
PHP bin2hex is an inbuilt function in PHP. It converts strings to hexadecimal values byte-wise with the high-nibble first. However, it does not convert strings representing binary digits to hexadecimal. In this article, we will discuss the PHP bin2hex Function. Also, we will discuss a few examples of using it ...
Read More
PHP chop is an inbuilt function in PHP. It removes whitespaces (or other characters) from the end of a string. In this article, we will discuss the PHP chop Function. Also, this function is an alias of PHP rtrim Function. Related Articles: PHP trim Function: Remove Characters from both Left ...
Read More
PHP chunk_split is an inbuilt function in PHP. It splits the input string into smaller chunks of the specified length. In this article, we will discuss the PHP chunk_split Function. Also, we will discuss a few examples of using it. Syntax string chunk_split($string, $length = 76, $end = "\r\n") Parameters ...
Read More
PHP hash is an inbuilt function in PHP. It generates a hash value of the input string using the algorithm of your choice. In this article, we will discuss the PHP hash Function. Also, we will discuss a few examples of using it. Syntax string hash($algo, $string, $getRawOutput = false) ...
Read More
PHP hex2bin is an inbuilt function in PHP. It converts a hexadecimal character sequence back to a binary string. However, it does not convert the hexadecimal string to binary number. In this article, we will discuss the PHP hex2bin Function. Also, we will discuss a few examples of using it ...
Read More
PHP html_entitiy_decode is an inbuilt function in PHP. It converts HTML Entities back to their corresponding characters. It works the opposite of PHP htmlentities Function. In this article, we will discuss the PHP html_entity_decode Function. Note: To convert characters to HTML entities, use the PHP htmlentities Function. Syntax html_entity_decode ($string, ...
Read More
The PHP htmlentities is an inbuilt function in PHP. It transforms all existing characters to their corresponding HTML Entities where applicable. In this article, we will discuss the PHP htmlentities Function. Also, we will discuss a few examples of using it. Note: To convert HTML entities back to characters, use ...
Read More
In HTML, certain characters have a special significance. They should be represented as HTML entities so as to preserve their meaning. PHP htmlspecialchars is an inbuilt function in PHP that converts certain special characters to HTML entities. In this article, we will discuss the PHP htmlspecialchars function. Also, we will ...
Read More
PHP htmlspecialchars_decode is an inbuilt function in PHP. It converts HTML Entities back to plain text characters. In this article, we will discuss the PHP htmlspecialchars_decode function. Also, we will discuss a few examples of using it. This function is the opposite of htmlspecialchars function. You can encode characters to ...
Read More
PHP implode Function is an inbuilt function of PHP. It joins elements of an array into a single string. It returns a string containing elements of the array. In this article, we discuss the PHP implode Function. Also, we will discuss a few examples demonstrating the usage of this function ...
Read More
The PHP lcfirst is an inbuilt function in PHP. It takes a string as the parameter and converts the first character lowercase. Also, it doesn't change other characters of the string. In this article, we will discuss the PHP lcfirst Function. Also, we will discuss a few examples of using ...
Read More
PHP ltrim is an inbuilt function in PHP. It removes whitespaces (or other characters) from the beginning of a string. In this article, we will discuss the PHP ltrim Function. Also, we will discuss a few examples of using it. Related Articles PHP trim Function: Remove Characters from both Left ...
Read More
PHP md5 is an inbuilt function in PHP. It returns the MD5 Hash of the string after hashing it with the RSA Data Security, Inc. MD5 Message-Digest Algorithm. Hashing a string is very important to store critical data in a database like for storing user's passwords. In this article, we ...
Read More
PHP nl2br is an inbuilt function in PHP. It inserts line breaks (<br/>) before every newline character in a string. The function supports the following newline characters: \r\n\r\n\n\r In this article, we will discuss the PHP nl2br Function. Also, we will discuss a few examples of using it. Syntax string ...
Read More
The PHP quotemeta is an inbuilt function in PHP. It accepts a string as an input and returns a string with a backslash in front of some characters. In this article, we will discuss the PHP quotemeta Function. Also, we will discuss a few examples of using it. The pre-defined ...
Read More
PHP rtrim is an inbuilt function in PHP. It removes whitespaces (or other characters) from the end of a string. In this article, we will discuss the PHP rtrim Function. Also, we will discuss a few examples of using it. Related Articles: PHP trim Function: Remove Characters from both Left ...
Read More
PHP sha1 is an inbuilt function in PHP. It returns the SHA-1 Hash of the string after hashing it with the US Secure Hashing Algorithm 1. Hashing a string is very important to store critical data in a database like for storing user's passwords. In this article, we will discuss ...
Read More
PHP str_ireplace Function is an inbuilt function in PHP. It replaces all the occurrences of a string or an array of string in another string or an array of string respectively in a case-insensitive manner. In this article, we will discuss the PHP str_ireplace Function. Also, we will discuss a ...
Read More
PHP str_repeat is an inbuilt function in PHP. It repeats a string for a specified number of times. Both the string and the number are the arguments to the function. In this article, we will discuss the PHP str_repeat Function. Also, we will discuss a few examples of using it ...
Read More
PHP str_replace Function is an inbuilt function in PHP. It replaces all the occurrences of a string or an array of string in another string or an array of string respectively. In this article, we will discuss the PHP str_replace Function. Also, we will discuss a few examples of using ...
Read More
PHP str_rot13 is an inbuilt string function in PHP. It performs ROT13 transformation on a string by excluding numeric and non-alphanumeric characters. Also, if you input an encoded string, the function returns the original string back. In this article, we will discuss the PHP str_rot13 Function. Also, we will discuss ...
Read More
PHP str_shuffle is an inbuilt function in PHP. It randomly shuffles all the characters of the input string without altering the original string. Also, it also works on numbers by treating them as strings. It returns a string which is one of the permutations of characters of the input string ...
Read More
PHP str_split is an inbuilt function in PHP. It converts a string into an array. Also, if you specify the length, it converts the string into sub-strings and returns them as array elements. In this article, we will discuss the PHP str_split Function. Also, we will discuss a few examples ...
Read More
PHP str_word_count is an inbuilt function in PHP. It returns information about the words in a string on the basis of input format. Also, it is mostly used to calculate the number of words in a string. In this article, we will discuss the PHP str_word_count function. Also, we will ...
Read More
PHP strcasecmp is an inbuilt Function in PHP. It compares two strings in a case-insensitive manner. Therefore, it treats lowercase and uppercase strings as the same values. The function compares and tells us if one string is greater, smaller or equal to the other string. In this article, we will ...
Read More
PHP strchr is an inbuilt function in PHP. It finds the first occurrence of a string in another string. Also, it returns the rest of the string after the first occurrence. In this article, we will discuss the PHP strchr Function. Note: This function is an alias of PHP strstr ...
Read More
PHP strcmp is an inbuilt Function in PHP. It compares two strings in a case-sensitive manner. Therefore, it treats lowercase and uppercase strings differently. The function compares and tells us if one string is greater, smaller or equal to the other string. In this article, we will discuss the PHP ...
Read More
PHP strip_tags is an inbuilt function in PHP. It removes all HTML, PHP tags and NULL bytes from a string after processing. It returns the same string after removing HTML and PHP tags. In this article, we will discuss the PHP strip_tags Function. Also, we will discuss a few examples ...
Read More
PHP stripos is an inbuilt function in PHP. It returns the position of the first occurrence of one string in another. It is very helpful in determining if a string exists in another string. In this article, we will discuss the PHP stripos Function. Also, we will discuss a few ...
Read More
PHP stripslashes is an inbuilt function in PHP. It removes backslashes from a string. You can use it recover the original string after escaping it using PHP addslashes Function. In this article, we will discuss the PHP stripslashes Function. Syntax stripslashes($string) Parameters The function expects only one parameter as shown ...
Read More
PHP stristr is an inbuilt function in PHP. It finds the first occurrence of a string in another string. Also, it returns the rest of the string after the first occurrence. In this article, we will discuss the PHP stristr Function. Also, we will discuss a few examples of using ...
Read More
PHP strlen is an inbuilt Function in PHP. It takes a string as parameter and returns it's length. Also, it calculates the length by including all whitespaces and special characters in the string. In this article, we will discuss the PHP strlen Function. Also, we will discuss a few examples ...
Read More
The PHP strncasecmp is an inbuilt function in PHP. It compares first n characters of two strings. The function compares and tells us if one string is greater, smaller or equal to the other string. Also, this function is case-insensitive. Therefore, it treats lowercase and uppercase characters as the same ...
Read More
The PHP strncmp is an inbuilt function in PHP. It compares first n characters of two strings. The function compares and tells us if one string is greater, smaller or equal to the other string. Also, this function is case-sensitive. Therefore, it treats lowercase and uppercase characters as different. In ...
Read More
PHP strpos is an inbuilt function in PHP. It returns the position of the first occurrence of one string in another. It is very helpful in determining if a string exists in another string. In this article, we will discuss the PHP strpos Function. Also, we will discuss a few ...
Read More
PHP strrchr is an inbuilt function in PHP. It finds the last occurrence of a character in a string and returns all characters till the end of the string. In this article, we will discuss PHP strrchr Function. Also, we will discuss a few examples of using it. You can ...
Read More
PHP strrev is an inbuilt function in PHP which reverses the input string. It takes a string in the parameter and returns the reverse of that string. In this article, we will discuss the PHP strrev Function. Also, we will discuss a few examples of using it. Syntax strrev ($input_string); ...
Read More
PHP strrpos is an inbuilt function in PHP. It returns the position of the last occurrence of one string in another. It is very helpful in determining if a string exists in another string. In this article, we will discuss the PHP strrpos Function. Also, we will discuss a few ...
Read More
PHP strstr is an inbuilt function in PHP. It finds the first occurrence of a string in another string. Also, it returns the rest of the string after the first occurrence. In this article, we will discuss the PHP strstr Function. Also, we will discuss a few examples of using ...
Read More
PHP strtok is an inbuilt function in PHP. It tokenizes a string into smaller parts according to the input delimiter values. It takes a string and the delimiters as input and returns a series of strings. In this article, we will discuss the PHP strtok Function. Also, we will discuss ...
Read More
PHP strtolower is an inbuilt function in PHP. It converts a PHP string to lowercase characters. In this article, we will discuss this function. Also, we will discuss a few examples of using it. Also, you can convert a string to uppercase characters using PHP strtoupper Function. Syntax strtolower ($string) ...
Read More
PHP strtoupper converts a PHP string to uppercase characters. In this article, we will discuss the PHP strtoupper Function. Also, we will discuss a few examples of using it. Also, you can convert a string to lowercase characters using PHP strtolower Function. Syntax strtoupper ($string) Parameters The strtoupper function expects ...
Read More
PHP substr is an inbuilt function in PHP which returns sub-string from a string. It is a very handy function for extracting a part of the string. In this post, we learn about the PHP substr function along with various examples. Syntax substr($string, $startIndex, $stringLength); Parameters The PHP substr function ...
Read More
PHP trim is an inbuilt function in PHP. It removes whitespaces (or other characters) from both the left and right sides of a string. In this article, we will discuss the PHP trim Function. Also, we will discuss a few examples of using it. To remove characters only from left ...
Read More
The PHP ucfirst is an inbuilt function in PHP. It takes a string as the parameter and converts the first character uppercase. Also, it doesn't change other characters of the string. In this article, we will discuss the PHP ucfirst Function. Also, we will discuss a few examples of using ...
Read More
PHP urldecode is an inbuilt function in PHP. It decodes a URL-encoded string back to a normal plain text string. In this article, we will discuss the PHP urldecode Function. Also, we will discuss a few examples of using it. In order to encode a string to make it convenient ...
Read More
PHP urlencode is an inbuilt function in PHP. It encodes a string so as to make it convenient to pass them as query parameters in the URL. The string consists of all non-alphanumeric characters except -, _ and . by replacing them with % sign followed by two hex digits ...
Read More
PHP wordwrap is an inbuilt function in PHP. It wraps a string to a given number of characters using a string break character. In this article, we will discuss the PHP wordwrap Function. Also, we will discuss a few examples of using it. Syntax string wordwrap ($string, $width, $break = ...
Read More