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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:49:38+00:00 2026-06-18T09:49:38+00:00

hi to all stackoverflow members, please help me with my problem regarding array manipulation.

  • 0

hi to all stackoverflow members, please help me with my problem regarding array manipulation.

stores_array:  
Array
(
    [0] => store1
    [1] =>store2
)  

items_array:  
Array  
(  
  [electronics]=>led tv  
  [cosmetics]=>eyeliner  
  [fruits]=>apple 
  [vegetables]=>cabbage  
)  

here is what i have so far:

$new_array = array();
  foreach($stores_array as $t) {
      $new_array[$t] = $items_array;
  }

    echo '<pre>';
    print_r($new_array);  
    echo '<pre/>';  

here is the output:

Array
(
[store1] => Array
    (
      [electronics]=>led tv  
      [cosmetics]=>eyeliner  
      [fruits]=>apple 
      [vegetables]=>cabbage  
    )  
[store2] => Array
    (
      [electronics]=>led tv  
      [cosmetics]=>eyeliner  
      [fruits]=>apple 
      [vegetables]=>cabbage  
    )

)  

here is what i want to achieve:
i wanted to add some other values in each of the array.
pls see the arrow i intend to add.

Array
(
[store1] => Array
    (
      [electronics]=>led tv  
      [cosmetics]=>eyeliner  
      [fruits]=>apple 
      [vegetables]=>cabbage
      [store]=>store1  <------- how can i add these?
    )  
[store2] => Array
    (
      [electronics]=>led tv  
      [cosmetics]=>eyeliner  
      [fruits]=>apple 
      [vegetables]=>cabbage 
      [store]=>store2  <------- how can i add these?
    )

)  

thanks you all in advance..

  • 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-18T09:49:39+00:00Added an answer on June 18, 2026 at 9:49 am

    Try this:

    $new_array = array();
    foreach($stores_array as $t) {
        $new_array[$t] = $items_array;
        $new_array[$t]["store"]=$t;
    }
    
    echo '<pre>';
    print_r($new_array);  
    echo '<pre/>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

*edit: I understand that stackoverflow has banned all questions regarding using Microsoft's Visio. I'm
Dear Stackoverflow Members, I have this JSON array, and it consists of the following
First of all, I have to thank StackOverflow and all its members for the
I have been all over stackoverflow and all over Google and I cannot seem
I've searched stackoverflow all day long to find an answer without luck, so here
After reading all sorts of Stackoverflow postings and various documentation including some on http://code.google.com/p/google-api-java-client/
All the stuff I'm finding on google or Stackoverflow are about the height of
StackOverflow uses the GZip encoding on all of their pages; the same seems to
I look all over the internet\goolge\stackoverflow and couldn't find full and simple guide that
I've been reading StackOverflow too much and started doubting all the code I've ever

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.