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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:31:18+00:00 2026-06-02T00:31:18+00:00

I have a post array like below: [quantity] => Array ( [5] => 10

  • 0

I have a post array like below:

[quantity] => Array
    (
        [5] => 10
        [23] => 20
    )

[price] => Array
    (
        [5] => 100.00 $
        [23] => 200.00 $
    )

[amount] => Array
    (
        [5] => 1,000.00 $  
        [23] => 4,000.00 $ 
    )

5 and 23 are id of product. And i need to convert it to :

[5]  => Array
     (
        [quantity] => 10
        [price]    => 100.00 $
        [amount]   => 1,000.00 USD
     )
[23] = => Array
     (
        [quantity] => 20
        [price]    => 200.00 $
        [amount]   => 4,000.00 USD
     )

How can i achieve this efficiently so that they can be ready for mysql insert?

  • 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-02T00:31:19+00:00Added an answer on June 2, 2026 at 12:31 am

    Walk through one of those arrays, acquire ID’s and reconstruct.

    Example:

    // YOUR DATA
    $quantity = array();
    $price = array();
    $amount = array();
    
    // NEW ARRAY
    $array = array();
    
    foreach ($quantity as $id => $itemQty) {
       $itemPrice = $price[$id];
       $itemAmount = $amount[$id];
       $array[$id] = array("quantity" => $itemQty, "amount" => $itemAmount, "price" => $itemPrice);
    }
    

    Now you have your data in $array sorted as you want.

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

Sidebar

Related Questions

Hi I have an array of Services ordered by user like below $_POST values
I have the following code: $postcode = $form->createElement('text', 'postcode'); $postcode->setLabel('Post code:'); $postcode->addValidator('regex', false, array('/^[a-z]{1,3}[0-9]{1,3}
I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
I have a form like the one below which is posted to contacts.php ,
I have a form to upload image like below <form name=sample enctype=multipart/form-data action=index.php method=post
When a form gets posted, I get some checkbox values like the below: Array
I have JS code something like shown below: function ValidateBid(source, args) { var txtValue
I have a linked list of arrays (struct at bottom of post) Each array
I'm stuck, I want to insert form data from array fields like below into
I have the HTML below <span class=post-labels> <a href=http://myblog.blogspot.com/search/label/jQuery%20Downloads>jQuery Donwloads</a> <a href=http://myblog.blogspot.com/search/label/jQuery>jQuery</a> <a href=http://myblog.blogspot.com/search/label/mootools>mootools</a>

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.