File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
solution/0100-0199/0125.Valid Palindrome Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,30 @@ func verify(ch byte) bool {
308
308
}
309
309
```
310
310
311
+ ### ** PHP**
312
+
313
+ ``` php
314
+ class Solution {
315
+ /**
316
+ * @param String $s
317
+ * @return Boolean
318
+ */
319
+ function isPalindrome($s) {
320
+ $regex = "/[a-z0-9]/";
321
+ $s = strtolower($s);
322
+ preg_match_all($regex, $s, $matches);
323
+ if ($matches[0] == Null) return true;
324
+ $len = floor(count($matches[0]) / 2);
325
+ for ($i = 0; $i < $len; $i++) {
326
+ if ($matches[0][$i] != $matches[0][count($matches[0]) - 1 - $i]) {
327
+ return false;
328
+ }
329
+ }
330
+ return true;
331
+ }
332
+ }
333
+ ```
334
+
311
335
### ** ...**
312
336
313
337
```
Original file line number Diff line number Diff line change @@ -296,6 +296,30 @@ func verify(ch byte) bool {
296
296
}
297
297
```
298
298
299
+ ### ** PHP**
300
+
301
+ ``` php
302
+ class Solution {
303
+ /**
304
+ * @param String $s
305
+ * @return Boolean
306
+ */
307
+ function isPalindrome($s) {
308
+ $regex = "/[a-z0-9]/";
309
+ $s = strtolower($s);
310
+ preg_match_all($regex, $s, $matches);
311
+ if ($matches[0] == Null) return true;
312
+ $len = floor(count($matches[0]) / 2);
313
+ for ($i = 0; $i < $len; $i++) {
314
+ if ($matches[0][$i] != $matches[0][count($matches[0]) - 1 - $i]) {
315
+ return false;
316
+ }
317
+ }
318
+ return true;
319
+ }
320
+ }
321
+ ```
322
+
299
323
### ** ...**
300
324
301
325
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param String $s
4
+ * @return Boolean
5
+ */
6
+ function isPalindrome ($s ) {
7
+ $regex = " /[a-z0-9]/" ;
8
+ $s = strtolower ($s );
9
+ preg_match_all ($regex , $s , $matches );
10
+ if ($matches [0 ] == Null ) return true ;
11
+ $len = floor (count ($matches [0 ]) / 2 );
12
+ for ($i = 0 ; $i < $len ; $i ++ ) {
13
+ if ($matches [0 ][$i ] != $matches [0 ][count ($matches [0 ]) - 1 - $i ]) {
14
+ return false ;
15
+ }
16
+ }
17
+ return true ;
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments