In computer programming, a string is an array or a sequence of characters. String is a basis data-type in PHP. PHP allows you to perform different operations on a string called PHP string manipulation for example, reversing words of a string, finding a portion of a string, encrypting a strings etc.
It is possible to access a portion of a string through substr() function.
This will produce following result
Using PHP's built in function substr_replace(), it is possible to change a portion of a string.
This will produce following result
Using PHP's built in function strlen(), it is possible to find the length of a string.
This will produce following result
Using PHP's built in function strrev(), it is possible to reverse a string. It will not change the case of the letters of the string.
This will produce following result
Using PHP's built in function strpos(), it is possible to search for the position of a given word in a string. If it finds the word in the string then the function returns the character position of its first match but If it does not find the word, function returns FALSE.
This will produce following result
Using PHP's built in function str_word_count(), it is possible to count number of words present in a string.
This will produce following result
Using PHP's built in function substr_count(), it is possible to count number of occurrences of a word in a string.
This will produce following result
Using PHP's built in function strpbrk(), it is possible to search for a set of characters in a string. The function returns the portion of the string from the first matched character to the end of the string. If no character in the set is found in the string, strpbrk() returns false .
This will produce following result
Using PHP's built in function mcrypt_ecb(), it is possible to encrypt and decrypt of a string. The function uses 'TripleDEC' encryption.
Note: These built in encryption function work with the mcrypt library.
Using PHP's built in function strtoupper() and strtolower(), it is possible to convert string in upper and lower case.
This will produce following result
Using PHP's built in function ucfirst() and ucwords(), it is possible to convert string in upper and lower case.
This will produce following result
Using PHP's built in function addslashes() and ucwords(), it is possible to escap certain charater in a string.
This will produce following result
Using PHP's built in function trim(), rtrim() and ltrim(), it is possible to remove whitespace from begining and end of a string.
This will produce following result
Using PHP's built in function parse_url() and parse_str(), it is possible to take raw URL. It is used to get the list of URL's constituent parts such as schema, domain, path and so on and return an associative array.
Using PHP's built in function urlencode() and urldecode(), it is possible to encode and decode url.
This will produce following result