File tree 3 files changed +73
-0
lines changed
solution/0400-0499/0412.Fizz Buzz
3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,32 @@ func fizzBuzz(n int) []string {
138
138
}
139
139
```
140
140
141
+ ### ** PHP**
142
+
143
+ ``` php
144
+ class Solution {
145
+ /**
146
+ * @param Integer $n
147
+ * @return String[]
148
+ */
149
+ function fizzBuzz($n) {
150
+ $rs = [];
151
+ for ($i = 1; $i <= $n; $i++) {
152
+ if ($i % 3 != 0 && $i % 5 != 0) {
153
+ array_push($rs, strval($i));
154
+ } else if ($i % 3 == 0 && $i % 5 != 0) {
155
+ array_push($rs, "Fizz");
156
+ } else if ($i % 3 != 0 && $i % 5 == 0) {
157
+ array_push($rs, "Buzz");
158
+ } else {
159
+ array_push($rs, "FizzBuzz");
160
+ }
161
+ }
162
+ return $rs;
163
+ }
164
+ }
165
+ ```
166
+
141
167
### ** ...**
142
168
143
169
```
Original file line number Diff line number Diff line change @@ -118,6 +118,32 @@ func fizzBuzz(n int) []string {
118
118
}
119
119
```
120
120
121
+ ### ** PHP**
122
+
123
+ ``` php
124
+ class Solution {
125
+ /**
126
+ * @param Integer $n
127
+ * @return String[]
128
+ */
129
+ function fizzBuzz($n) {
130
+ $rs = [];
131
+ for ($i = 1; $i <= $n; $i++) {
132
+ if ($i % 3 != 0 && $i % 5 != 0) {
133
+ array_push($rs, strval($i));
134
+ } else if ($i % 3 == 0 && $i % 5 != 0) {
135
+ array_push($rs, "Fizz");
136
+ } else if ($i % 3 != 0 && $i % 5 == 0) {
137
+ array_push($rs, "Buzz");
138
+ } else {
139
+ array_push($rs, "FizzBuzz");
140
+ }
141
+ }
142
+ return $rs;
143
+ }
144
+ }
145
+ ```
146
+
121
147
### ** ...**
122
148
123
149
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param Integer $n
4
+ * @return String[]
5
+ */
6
+ function fizzBuzz ($n ) {
7
+ $rs = [];
8
+ for ($i = 1 ; $i <= $n ; $i ++ ) {
9
+ if ($i % 3 != 0 && $i % 5 != 0 ) {
10
+ array_push ($rs , strval ($i ));
11
+ } else if ($i % 3 == 0 && $i % 5 != 0 ) {
12
+ array_push ($rs , " Fizz" );
13
+ } else if ($i % 3 != 0 && $i % 5 == 0 ) {
14
+ array_push ($rs , " Buzz" );
15
+ } else {
16
+ array_push ($rs , " FizzBuzz" );
17
+ }
18
+ }
19
+ return $rs ;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments