We are given two strings, we need to check if strings are Anagram.
Input : "anagram", "nagaram" Output : yes Input : "mat", "fat" Output : no
We use the below inbuilt function to solve this problem:
- count_chars(): this function generally has syntax count_chars(string, return_mode) is use to perform several operations related to string. This parameter is optional. It takes value to 0, 1, 2, 3, 4.
The idea to solve this problem using the above mentioned function is, to use value 1 i.e. in this chosen mode the above function will return an array with key value pairs, where keys are ASCII values and corresponding values will be the number of occurrences of that ASCII value. The array possess only those keys as ASCII values whose frequency is more than 0.
- PHP | Program to check a string is a rotation of another string
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | Palindrome Check
- PHP | check if a number is Even or Odd
- PHP | Check if a number is prime
- PHP | Check if a number is Perfect number
- PHP | Check if a number is armstrong number
- PHP to check substring in a string
- PHP | Check if all characters are lower case
- PHP | ctype_alnum() (Check for Alphanumeric)
- How to check an array is associative or sequential in PHP?
- How to check whether an array is empty using PHP?
- Why to check both isset() and !empty() function in PHP ?
- How to check form submission in PHP ?
- How to check if URL contain certain string using PHP?
- PHP | Check if a variable is a function
- PHP | Check if two arrays contain same elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.