Skip to content

Commit cba9566

Browse files
authored
feat: add php solution to lc problem: No.0027 (#901)
No.0027.Remove Element
1 parent 61c42d7 commit cba9566

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

solution/0000-0099/0027.Remove Element/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,26 @@ impl Solution {
172172
}
173173
```
174174

175+
### **PHP**
176+
177+
```php
178+
class Solution {
179+
180+
/**
181+
* @param Integer[] $nums
182+
* @param Integer $val
183+
* @return Integer
184+
*/
185+
function removeElement(&$nums, $val) {
186+
for ($i = count($nums) - 1; $i >= 0; $i--) {
187+
if ($nums[$i] == $val) {
188+
array_splice($nums, $i, 1);
189+
}
190+
}
191+
}
192+
}
193+
```
194+
175195
### **...**
176196

177197
```

solution/0000-0099/0027.Remove Element/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@ impl Solution {
167167
}
168168
```
169169

170+
### **PHP**
171+
172+
```php
173+
class Solution {
174+
175+
/**
176+
* @param Integer[] $nums
177+
* @param Integer $val
178+
* @return Integer
179+
*/
180+
function removeElement(&$nums, $val) {
181+
for ($i = count($nums) - 1; $i >= 0; $i--) {
182+
if ($nums[$i] == $val) {
183+
array_splice($nums, $i, 1);
184+
}
185+
}
186+
}
187+
}
188+
```
189+
170190
### **...**
171191

172192
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
3+
/**
4+
* @param Integer[] $nums
5+
* @param Integer $val
6+
* @return Integer
7+
*/
8+
function removeElement(&$nums, $val) {
9+
for ($i = count($nums) - 1; $i >= 0; $i--) {
10+
if ($nums[$i] == $val) {
11+
array_splice($nums, $i, 1);
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)