3
21/10/2024 1:42 pm
Topic starter
A palindrome is a number which reads the same backward as forward, such as 323 or 1001. Write a program which reads a positive integer numbers until you receive "END", for each number print whether the number is palindrome or not.
Examples:
1 Answer
2
21/10/2024 1:43 pm
I've used strrev() php function for this task; Here is my solution:
<?php $input = readline(); while ($input != "END") { echo isPalindrome($input);//echo the function isPalindrome() $input = readline(); } function isPalindrome($str) { if ($str === strrev($str)) { $result = "true" . PHP_EOL; } else { $result = "false" . PHP_EOL; } return $result; }