Technical Question: How can you determine if a word is a palindrome?

A simple technical question that may be given is how can you determine if a word is a palindrome or not? A palindrome is a word that can be spelled forward and backwards the same way.

Some example palindromes are:

  • madam
  • anna
  • civic
  • kayak
  • level
  • racecar
  • noon
  • mom
  • dad

A way to solve this in PHP is to take your string, split it into an array, reverse the contents of the array, and turn it back into a string. An even simpler way is to use the ‘strrev’ function, but that takes away all the fun now doesn’t it?

Leave a Reply

Your email address will not be published. Required fields are marked *