Need a code check for a PHP do/while loop, please!

Hello, Codecademy community.

I am currently working through the PHP modules that are accessible via Google search, specifically the module exercise where you create your own do/while loop.

The module suggests the following:

If you’re having trouble thinking of what to do and you’re looking for a challenge, you could try a variation on the coin flipping loop in exercise 5. This time, roll a six-sided die until you get a six!

To do this, you will need to assign rand(1,6) to a variable $roll and then continue the the loop on the condition $roll != 6.

Make sure you echo $roll in some way so you know if the loop is working.

I wanted to challenge myself by incorporating some of the other concepts I’ve been taught thus far, so I wrote the code depicted in the attached image. Also shown in said image is the intended output. However, upon submitting the code the program does not accept it - it freezes, with the “cog” icon endlessly rotating. I know the PHP modules have technically been removed, and are therefore buggy due to lack of maintenance, but I just wanted someone to verify the code is correctly written.

Note: I had to modify the condition so that it would be less than 5, because upon manual evaluation of the array_rand function, I noticed the code would never generate a 6. Yet, surprisingly, it would generate a 0, even though it was not an item in the array. Could any shed some light on why this occurs, as well?

Thank you in advance!

15 PM|690x427