If you’re using integers, this sounds like an excellent case for a switch statement…

Also, consider this:

$starNumber > 1 || $starNumber < 2 )…

($starNumber > 2 || $starNumber <3)

What happens if the number is EXACTLY 2? Which of your cases matches? (EDIT: Actually, it does catch, but it **shouldnt**

Let’s try cleaning this up a bit at least. We need to redefine our cases.

Your cases currently are:

Number = 0

Number > 1 OR Number < 2

Number > 2 OR Number < 3

Number > 3 OR Number < 4

There’s some gaps here, and some massive overlaps.

Lets consider your second condition: Number > 1 OR Number < 2.

Welll… every number greater than 1 makes the first half of the condition True.

every number less than 2 makes the second half of the condition True.

Consider 0.5.

It’s not greater than 1. So False.

If IS less than 2. So True.

False OR True = True. So 0.5 is a 1 star.

Consider -50

It’s not greater than 1. So False.

It IS less than 2. So True.

False OR True = True. So -50 is a 1 star.

Consider 100

It’s IS greater than 1. So True.

It is not less than 2. So False.

True OR False = True. So 100 is a 1 star.

So… EVERYTHING that isnt 0, will be a 1 star in your system.

What do we change?

Well, we can start by making the OR’s into AND’s. That will solve the huge over-steps, because True AND False is False.

Our next step is to include the lower boundary in the logic; namely a 1 should be a 1-star, so we dont want to look for things that are greater than 1, we want to look for things that are greater than *or equal to* 1.

Our next step is to determine than 0-star scores actually account for anything less than 1, and not just 0.

The fourth step is a logical flow connection of if-elseif-else statements.

if the score is 2.5, we start at the beginning of the if

`if (score < 1) {....}`

It’s not less than 1, so we move to the next elseif.

`elseif (score >= 1 && score < 2)`

perfectly valid line, but here’s the thing: We already KNOW it’s not < 1, or we wouldnt have gotten here. So the first bit is actually redundant; everything that is not < 1, is >= 1. So we only actually need to test `elseif (score < 2)`

.