Skip to content

Instantly share code, notes, and snippets.

@fajarwz
Created June 25, 2021 15:01
Show Gist options
  • Save fajarwz/5d17f85e8b36c3a9c8d4c5132df76d71 to your computer and use it in GitHub Desktop.
Save fajarwz/5d17f85e8b36c3a9c8d4c5132df76d71 to your computer and use it in GitHub Desktop.
Palindrome checker using PHP
<?php
function isPalindrome($string) {
for($i = 0, $j = strlen($string) - 1; $i < strlen($string) / 2; $i++, $j--) {
if($string[$i] != $string[$j]) {
return 'false';
}
}
return 'true';
}
echo isPalindrome("tutut");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment