Skip to content

Commit cd6fd0b

Browse files
authored
feat: add php solution to lcof problem: No.05 (#1009)
1 parent 6d0fc46 commit cd6fd0b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lcof/面试题05. 替换空格/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,25 @@ public class Solution {
218218
}
219219
```
220220

221+
### **PHP**
222+
223+
```php
224+
class Solution {
225+
/**
226+
* @param String $s
227+
* @return String
228+
*/
229+
function replaceSpace($s) {
230+
$rs = "";
231+
for ($i = 0; $i < strlen($s); $i++) {
232+
if ($s[$i] === " ") $rs = $rs."%20";
233+
else $rs = $rs.$s[$i];
234+
}
235+
return $rs;
236+
}
237+
}
238+
```
239+
221240
### **...**
222241

223242
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
/**
3+
* @param String $s
4+
* @return String
5+
*/
6+
function replaceSpace($s) {
7+
$rs = "";
8+
for ($i = 0; $i < strlen($s); $i++) {
9+
if ($s[$i] === " ") $rs = $rs."%20";
10+
else $rs = $rs.$s[$i];
11+
}
12+
return $rs;
13+
}
14+
}

0 commit comments

Comments
 (0)