Harrington Web

Palindrome

Wednesday, June 7, 2006

One of the first kinds of programs learned by a student is how to determine if a string is a palindrome. A palindroms is a word or string that is spelled the same backwords as it is forwards. An example would be "rotor".

<?php
    $test="rotor";
    if ($test == strrev($test)) {
          echo "This is a palindrome";
        } else {
        echo "This is NOT a palindrome";
        }
?>