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 226817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:32:48+00:00 2026-05-11T19:32:48+00:00

i have an issue i need to fix sooner than later. if i had

  • 0

i have an issue i need to fix sooner than later. if i had the time to rewrite the entire script i would, but such is the life of a programmer, right? anywho, i’ve taken over a project and i have a multidimensional mixed associative/numeric array like so:

Array
(
    [item1] => Array
        (
            [dataset] => Array()
            [3] => Array()
            [7] => Array()
        )
    [item2] => Array
        (
            [dataset] => Array()
            [4] => Array()
            [19] => Array()
            [2] => Array()
        )
)

what i need to do is shift the dataset index in each of the itemX indexes to be the last index to result this:

Array
(
    [item1] => Array
        (
            [3] => Array()
            [7] => Array()
            [dataset] => Array()
        )
    [item2] => Array
        (
            [4] => Array()
            [19] => Array()
            [2] => Array()
            [dataset] => Array()
        )
)

a few things that may help make this happen is that i know that the dataset index will always be the first index in the itemX index and the key will always be ‘dataset’ and the others will all always be numeric indexes. is there anyway to do this in php? the fact that it’s a mixed array is throwing me. i can’t have the numeric indexes getting reset and starting at 0. it doesn’t matter if they’re order is shifted, only that they all come before the ‘dataset’ index. maybe it’s just one of those days…. :\ any suggestions or comments are greatly appreciated.

  • 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-05-11T19:32:49+00:00Added an answer on May 11, 2026 at 7:32 pm

    Loop though all elements like this:

    foreach ($all_items as $key =>$items) {
       $dataset = $items['dataset'];
       unset($all_items[$key]['dataset']); // Removing it (from the top)
       $all_items[$key]['dataset'] = $dataset; // Adding it again (at the bottom)
    }
    

    Unsetting the ‘dataset’ element and adding it again will cause the element to be added at the bottom.

    It’s important that you modify the original array directly, not the $items from the foreach, because those changes will not affect the original array.

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

Sidebar

Related Questions

I have searched for this but nobody have the same issue.. Now I need
I don't know how to fix or handle this issue. But I currenlty have
We have an issue where we need to modify keys for users that are
I rarely use SQL and have a unique issue I need to solve. I
I have an issue with a my SQL query. I need to execute a
So here's my issue. I have an image that I need to shrink. The
I have a strange issue that I'm not too sure on how to fix
I am using Magento and I'm trying to fix a small issue I have
I'm trying to fix an issue, in my application I have this code try
I have been trying desperately to fix this issue where my ListView items are

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.