Write a PHP function to check if a given string is a palindrome

<?php
function isPalindrome($str) {
    $reversed = strrev($str);
    return strtolower($str) === strtolower($reversed);
}

// Example usage:
$result = isPalindrome('level');
echo $result ? 'Palindrome' : 'Not a Palindrome';
?>

 

Post your Answer