| Conditions | 4 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function isPalindrome(string $s): bool |
||
| 10 | { |
||
| 11 | if (0 === ($n = strlen($s))) { |
||
| 12 | return true; |
||
| 13 | } |
||
| 14 | $ans = []; |
||
| 15 | for ($i = 0; $i < $n; $i++) { |
||
| 16 | // Can also use ctype_alnum instead. |
||
| 17 | if (preg_match('/^[a-zA-Z0-9]$/', $s[$i])) { |
||
| 18 | array_push($ans, strtolower($s[$i])); |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | return $ans === array_reverse($ans); |
||
| 23 | } |
||
| 73 |