mirror of
https://github.com/TheAlgorithms/PHP.git
synced 2025-07-10 11:36:21 +02:00
20 lines
399 B
PHP
20 lines
399 B
PHP
<?php
|
|
|
|
/**
|
|
* This function checks if given number is palindromic
|
|
* e.g. 121
|
|
* @param integer $input
|
|
* @return boolean
|
|
*/
|
|
function isNumberPalindromic(int $input): bool
|
|
{
|
|
$arr = array_map('intval', str_split($input));
|
|
$arrRev = array_reverse($arr);
|
|
$inputRev = (int)implode("", $arrRev);
|
|
if ($input == $inputRev) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|