Skip to content
Exercise · Strings · lesson 9 of 9

Exercise: palindrome

Write a function function isPalindrome($text) that returns true if the string reads the same from left to right and from right to left, and false otherwise. Letter case and spaces do not count.

  • isPalindrome('А роза упала на лапу Азора') → true
  • isPalindrome('Шалаш') → true
  • isPalindrome('abc') → false

Constraints: the string holds only Russian and Latin letters and spaces; an empty string is a palindrome.

Do not add extra require or use lines unless the task says so explicitly.

palindrome.php — php
php · 7 lines
Ctrl+Enter run · Esc leave editor