Always 2 happy hobbits in PHP

A

Administrator

admin

by admin , in category: PHP , 2 months ago

Always 2 happy hobbits in PHP 🤗 Not sure why do we need switch in this case 🤣


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$numberOfHobbits = 2;
switch ($numberOfHobbits)
{
    case 1: 
        echo "1 sad hobbit";
        break;
    case 2: 
        echo "2 happy hobbits";
        break;
    case 3: 
        echo "3 hobbits are a crowd";
        break;
    default: 
        echo "All hobbits have gone home";
}
Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers