/    Sign up×
Community /Pin to ProfileBookmark

I don’t get it… I understand how to write one out, but what would you use it for or how, exactly?

Here’s the example:

[code=php]
switch ($x)
{
case 1:
echo “Number 1”;
break;
case 2:
echo “Number 2”;
break;
case 3:
echo “Number 3”;
break;
default:
echo “No number between 1 and 3”;
}
[/code]

And here is what I came up with, but dunno how to use it.

[code=php]
$today=date(“D”);

switch ($today)
{
case 1:
echo “Today is only Thursday, almost wknd”;
break;
case 2:
echo “YAY!!! Its Finally Friday”;
break;
case 3:
echo “Damn, tomorrow already Monday”;
break;
default:
echo “Still a long way till the wknd”;
}
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 03.2008 — Ok... I've added:

echo "today is $today. ";

Result:

Today is Thu. Still a long way till the wknd

So Im still getting the default value coming up.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 03.2008 — [code=php]$today=date("D");
echo "Today is $today. ";

switch ($today)
{
case Thu:
echo "Today is only Thursday, almost wknd";
break;
case Fri:
echo "YAY!!! Its Finally Friday";
break;
case Sun:
echo "Damn, tomorrow already Monday";
break;
default:
echo "Still a long way till the wknd";
}[/code]
×

Success!

Help @Hooded_Villian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...