Skip to content

Commit

Permalink
feat: add php solution to lcof problem: No.05 (doocs#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu-IT authored May 11, 2023
1 parent 6d0fc46 commit cd6fd0b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lcof/面试题05. 替换空格/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ public class Solution {
}
```

### **PHP**

```php
class Solution {
/**
* @param String $s
* @return String
*/
function replaceSpace($s) {
$rs = "";
for ($i = 0; $i < strlen($s); $i++) {
if ($s[$i] === " ") $rs = $rs."%20";
else $rs = $rs.$s[$i];
}
return $rs;
}
}
```

### **...**

```
Expand Down
14 changes: 14 additions & 0 deletions lcof/面试题05. 替换空格/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
/**
* @param String $s
* @return String
*/
function replaceSpace($s) {
$rs = "";
for ($i = 0; $i < strlen($s); $i++) {
if ($s[$i] === " ") $rs = $rs."%20";
else $rs = $rs.$s[$i];
}
return $rs;
}
}

0 comments on commit cd6fd0b

Please sign in to comment.