Skip to content

Instantly share code, notes, and snippets.

@Vigowebs
Created November 21, 2022 19:21
Show Gist options
  • Save Vigowebs/f8f863e2a09aa2ae283b57c432cbae87 to your computer and use it in GitHub Desktop.
Save Vigowebs/f8f863e2a09aa2ae283b57c432cbae87 to your computer and use it in GitHub Desktop.
Write an anagram using PHP
function is_anagram($a, $b) {
return(count_chars($a, 1) == count_chars($b, 1));
}
//Example:
$a = 'Silent';
$b = 'Listen';
echo is_anagram($a,$b); // output: 1
$a = 'bat';
$b = 'Tap';
echo is_anagram($a,$b); // output (empty):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment