/    Sign up×
Community /Pin to ProfileBookmark

No return value from function?

Hi!

Is it possible to put a Switch/Case into a function? I can’t get it to work. I want the value from the Switch/Case value to be returned from the function?!

Please have a look at the code below:

// Date – Name of the day in number 0 – 6 (0 = Sunday)
$day_name_number = date(“w”);

Translation_Days($day_name_number);

function Translation_Days($x)
{
// Translate the name of the day to swedish name
switch ($x)
{
case 0:
$day_name = “Söndag”;
break;

case 1:
$day_name = “Måndag”;
break;

case 2:
$day_name = “Tisdag”;
break;

case 3:
$day_name = “Onsdag”;
break;

case 4:
$day_name = “Torsdag”;
break;

case 5:
$day_name = “Fredag”;
break;

case 6:
$day_name = “Lördag”;
break;
}

return $day_name;

}

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 05.2009 — Did you try echoing the result?
[code=php]
echo Translation_Days($day_name_number);
[/code]
×

Success!

Help @pkng 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...