Conditions | 6 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | public static function isPalindrome2(string $s): bool |
||
26 | { |
||
27 | if (empty($s)) { |
||
28 | return true; |
||
29 | } |
||
30 | [$i, $j] = [0, strlen($s) - 1]; |
||
31 | while ($i < $j) { |
||
32 | if (!ctype_alnum($s[$i])) { |
||
33 | $i++; |
||
34 | } elseif (!ctype_alnum($s[$j])) { |
||
35 | $j--; |
||
36 | } elseif (strtolower($s[$i]) !== strtolower($s[$j])) { |
||
37 | return false; |
||
38 | } else { |
||
39 | $i++; |
||
40 | $j--; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return true; |
||
45 | } |
||
73 |