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

  • Home
  • SEARCH
  • 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 8482997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:57:59+00:00 2026-06-10T19:57:59+00:00

Even though I have read the PHP documentation and this looks like to be

  • 0

Even though I have read the PHP documentation and this looks like to be a FAQ, it’s still giving me some headache.

I have an array like this which holds the months of the year:

[12] => december
 [4] => april
 [3] => march
 [6] => june
 [7] => july
[10] => october

...and so on

The order is not as it should be. I want to reorder the keys numerically. I can swap the keys with values if I want, but while each numerical value will match the corresponding month, they will never be in order. So I thought of putting these in order via PHP.

I have tried with $calendar = ksort( $myarray );

But If I try to print $calendar, I will only get bool=true or array with a single key and “1” as value… I was planning to use the ksort result in a foreach later, but I can’t.

What I’m droing wrong?

  • 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-10T19:58:01+00:00Added an answer on June 10, 2026 at 7:58 pm

    No .. just use:

    ksort($myarray);
    print_r($myarray)
    

    Codepad example

    ksort() sorts an array by key, maintaining key to data correlations, returns TRUE on success or FALSE on failure, if you associate the $calendar with ksort() you will have what ksort returns.

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

Sidebar

Related Questions

PHP's documentation on this function is a bit sparse and I have read that
Even though I have a fermi card(gtx 560) I get this error on VS2010:
I have searched this site and Google and even though the idea is pretty
I have this error appearing in my web service and even though I'v had
I've heard of GAE and even though it doesn't support PHP, people have gotten
Even though I have read a lot about it I can't get my head
I have some html like this <form id=reportform method='post'> <input type='hidden' id='qid' name='qid' value=<?php
Why two object's hash code is not same even though they have similar values.
I can't send email to my app users, even though I have the permissions.
I have a problem of web pages being cached even though I specify that

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.