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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:29:20+00:00 2026-05-13T21:29:20+00:00

Basically my app is interacting with a web service that sends back a weird

  • 0

Basically my app is interacting with a web service that sends back a weird multidimensional array such as:

Array
(
    [0] => Array
        (
            [Price] => 1
        )
    [1] => Array
        (
            [Size] => 7
        )
    [2] => Array
        (
            [Type] => 2
        )
)

That’s not a problem, but the problem is that the service keeps changing the index of those items, so in the next array the Price could be at 1 instead of 0.

How do I effeciently transform arrays like this into a single dimension array so I can access the variables through $var[‘Size’] instead of $var[1][‘Size’]?

Appreciate your 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-05-13T21:29:20+00:00Added an answer on May 13, 2026 at 9:29 pm

    Like this:

    $result = array();
    
    foreach($array as $inner) {
        $result[key($inner)] = current($inner);        
    }
    

    The $result array would now look like this:

    Array
    (
        [Price] => 1
        [Size] => 7
        [Type] => 2
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I am trying to restart a service from a php web page. Here
I would like to write an android app that basically layers an overlay on
Basically the app writes the contents of a Collection to XML. I'm using XMLStreamWriter
Basically I’ve heard that certain conditions will cause .NET to blow past the finally
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am trying to migrate a simple WinForms app to a ASP.Net web app.
I am writing a component for a web app which will display some html,
Basically my app loads two RSS feeds - a blog feed and a twitter
(Very) basically my app is just a load of information collected from the internet

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.