Given three values $a, $b, and $c, the biggest is the one that is greater than or equal to both of the others.
Remember
Example: a = 14, b = 7, c = 22
22 >= 14 and 22 >= 7 → biggest is 22
Ties: a = 10, b = 10, c = 3
either 10 is a valid maximum
a
b
c
Biggest
14
7
22
22
10
10
3
10
-5
-2
-9
-2
5
5
5
5
Approach
How to Find the Biggest of Three Numbers in PHP
Compare pairwise (or call max) and prefer >= so ties stay correct.
If $a >= $b and $a >= $c, return $a.
Else if $b >= $a and $b >= $c, return $b.
Otherwise return $c.
Shortcut: max($a, $b, $c).
Method
Idea
Time
Best for
If-else ladder
Explicit >= checks
O(1)
Interviews, default
max()
max($a, $b, $c)
O(1)
Short production code
Nested max
max($a, max($b, $c))
O(1)
Teaching pairwise max
Pseudocode
Pseudocode
function Biggest(a, b, c):
if a >= b and a >= c:
return a
if b >= a and b >= c:
return b
return c
Reference
Cheat Sheet
Keep these patterns handy while coding.
Topic
Detail
a wins
$a >= $b && $a >= $c
b wins
$b >= $a && $b >= $c
else
return $c
One-liner
max($a, $b, $c)
Many values
Use a running-max loop (see Maximum of Array)
Try it
Live Preview
Enter three numbers to see which is biggest.
Integers and decimals both work. Tap a chip or type your own values.
Result
a = 14, b = 7, c = 22
biggest = 22
Trace
Worked Walkthrough — 14, 7, 22
Apply the if-else ladder step by step.
Calculation
a = 14, b = 7, c = 22
Is a >= b and a >= c?
14 >= 7 → true
14 >= 22 → false
→ a is not the biggest
Is b >= a and b >= c?
7 >= 14 → false
→ b is not the biggest
Otherwise return c
biggest = 22
Code
PHP Programs
Start with an if-else ladder, then use max(), and finish with nested pairwise max.
Example 1 — If-Else Ladder
Explicit comparisons with >= — the interview default.