Last active
December 8, 2016 08:43
-
-
Save ALTELMA/7906d55d8246bd95a3ccd9b9132345fd to your computer and use it in GitHub Desktop.
PHP Practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_anagram($a, $b) { | |
return(count_chars($a, 1) == count_chars($b, 1)); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function palindrome($str) { | |
if ((strlen($str) == 0)) { | |
return false; | |
} | |
if ((strlen($str) == 1)) { | |
return true; | |
} else { | |
if (substr($str,0,1) == substr($str,(strlen($str) - 1),1)) { | |
return palindrome(substr($str,1,strlen($str) -2)); | |
} else { | |
return false; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment