From the course: PHP Practice Challenges

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Fizz Buzz

Fizz Buzz

(electronic music) - [Instructor] Some problems are purely academic but get you to think a certain way. And this example, on top of being purely academic, is a favorite for job interviews. FizzBuzz is a classic problem that has you print all numbers from 1 to 100, inclusive, while making important substitutions. Here are the requirements: Replace all multiples of 3 with the word Fizz, replace all multiples of 5 with the word Buzz, and replace any numbers that are multiples of 3 and 5 with the word FizzBuzz. There are a lot of different ways to implement this solution, so definitely work through one that feels right for you. And there's no starter file for this, you'll be starting completely from scratch. Go ahead and pause this video here to write your own, then we'll look at the solution I came up with. (electronic music) Welcome back! Let's get to solving this classic problem. I'll open up my php tags and the first thing I'll do is write our incrementor, $i = 1; Then we'll work…

Contents