Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:59:07+00:00 2026-06-12T16:59:07+00:00

Possible Duplicate: In PHP given a month string such as “November” how can I

  • 0

Possible Duplicate:
In PHP given a month string such as “November” how can I return 11 without using a 12 part switch statement?

I have weekdays in a specific format that I need to convert to another format and ultimately translate them, as well. I need to do this at runtime, meaning I cannot change the format in which the dates are stored, but have to convert them for the final output on the website.

Now, of course I could just create seven if-statements to do this, like

if ($wkday == "Mon") { $wkday = "Monday"; }
if ($wkday == "Tue") { $wkday = "Tuesday"; }

…

But I’m trying to find a neater way to do this, like putting both input and output values in arrays and comparing them to one another, to cut down the number of ugly if-statements. It’s not so bad in this case, seeing that there are only seven possible values, but I’d like to do it right and learn for the future. 🙂 I tried to search for this, but don’t even know what terminology to use. I’ll be grateful for any hint.

Thanks for you help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:59:08+00:00Added an answer on June 12, 2026 at 4:59 pm

    An array would be useful here, and in this case it would be similar to a hashmap in Java.

    $wkday = "Thu";
    $wkdayMapper = array(
      "Mon" => "Monday",
      "Tue" => "Tuesday",
      "Wed" => "Wednesday",
      "Thu" => "Thursday",
      "Fri" => "Friday",
      "Sat" => "Saturday",
      "Sun" => "Sunday"
    );
    
    echo $wkdayMapper[$wkday]; //Thursday
    

    PHP manual link on arrays

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: In PHP given a month string such as “November” how can I
Possible Duplicate: Can you “compile” PHP code? After I write an application in PHP,
Possible Duplicate: “Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given” error while
Possible Duplicate: Given a time, how can I find the time one month ago
Possible Duplicate: Converting string to MySQL timestamp format in php Given a date in
Possible Duplicate: Php: remove all tags, but “a href” in a text Is there
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I have a member.php
Possible Duplicate: PHP iterate days of month given month and year Obtain all days
Possible Duplicate: Cache Object in PHP without using serialize So I have built a
Possible Duplicate: “Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given” error while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.