Check if Palindrome

Check if a string is a palindrome by comparing characters from both ends.

Code

Algorithms
$clean = preg_replace('/[^a-z0-9]/', '', strtolower($s));
return $clean === strrev($clean);

Parameters

The string to check

Server

More PHP Snippets