Skip to content

feat: add php solution to lc problem: No.0412 #942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions solution/0400-0499/0412.Fizz Buzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,32 @@ func fizzBuzz(n int) []string {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer $n
* @return String[]
*/
function fizzBuzz($n) {
$rs = [];
for ($i = 1; $i <= $n; $i++) {
if ($i % 3 != 0 && $i % 5 != 0) {
array_push($rs, strval($i));
} else if ($i % 3 == 0 && $i % 5 != 0) {
array_push($rs, "Fizz");
} else if ($i % 3 != 0 && $i % 5 == 0) {
array_push($rs, "Buzz");
} else {
array_push($rs, "FizzBuzz");
}
}
return $rs;
}
}
```

### **...**

```
Expand Down
26 changes: 26 additions & 0 deletions solution/0400-0499/0412.Fizz Buzz/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ func fizzBuzz(n int) []string {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer $n
* @return String[]
*/
function fizzBuzz($n) {
$rs = [];
for ($i = 1; $i <= $n; $i++) {
if ($i % 3 != 0 && $i % 5 != 0) {
array_push($rs, strval($i));
} else if ($i % 3 == 0 && $i % 5 != 0) {
array_push($rs, "Fizz");
} else if ($i % 3 != 0 && $i % 5 == 0) {
array_push($rs, "Buzz");
} else {
array_push($rs, "FizzBuzz");
}
}
return $rs;
}
}
```

### **...**

```
Expand Down
21 changes: 21 additions & 0 deletions solution/0400-0499/0412.Fizz Buzz/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
/**
* @param Integer $n
* @return String[]
*/
function fizzBuzz($n) {
$rs = [];
for ($i = 1; $i <= $n; $i++) {
if ($i % 3 != 0 && $i % 5 != 0) {
array_push($rs, strval($i));
} else if ($i % 3 == 0 && $i % 5 != 0) {
array_push($rs, "Fizz");
} else if ($i % 3 != 0 && $i % 5 == 0) {
array_push($rs, "Buzz");
} else {
array_push($rs, "FizzBuzz");
}
}
return $rs;
}
}