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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:31:45+00:00 2026-05-18T12:31:45+00:00

So I have lots of arrays of the form: $e = array( key1 =>

  • 0

So I have lots of arrays of the form:

$e = array( 
  "key1" => "value1",
  "key2" => "value2",
  "key3" => "value3",
  "key4" =? "value4"
);

And another array just declared as:

$a = array( );

What I want is to append $e to $a as an element, so

$a[0] = array( 
  "key1" => "value1",
  "key2" => "value2",
  "key3" => "value3",
  "key4" =? "value4"
);

So I can then go:

$count = count( $a );
for ( $j = 0; $j < $count; $j++ )
{
  echo $a[$j]["key1"];
}

and it will print “value1”.

I will be repeating this process for all of the $e, so $a may not always be empty when the $e is appended – it may have had other $e appended previously. I thought that array_push would do this but it doesn’t. Thanks for any 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-18T12:31:46+00:00Added an answer on May 18, 2026 at 12:31 pm

    The quick and dirty way is pretty simple:

    $a[] = $e;
    

    and then do it again for any additional arrays. That will fill in the $a array starting with index zero and incrementing up.

    If you wanted to use some sort of keys, you could do:

    $a['firstarray'] = $e;
    

    and accomplish much the same thing. The difference is that since keys must be unique, a screwup in that second method could overwrite an existing element. The first method has no chance of that happening.

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

Sidebar

Related Questions

I have two arrays. In each array I have objects with lots of properties
I have lots of details. I want to stack them within an array, can
I have an array with lots of items with same names like CloudObserverCMSStub edited
note from N00B land again. I have read lots about sorting arrays - wanted
I have a nested array grouping three other arrays: $online, $busy and $offline, in
So I have a list with lots of items like below: <ul id=usersList> <li><FORM><INPUT
i have a three arrays in javascript var array1 = new Array (1,2,3,4,5); var
I have two arrays $brands = Array (1=>a, 2=>b); $titles = Array (1=>d, 2=>e);
So I have two arrays Array ( [0] => test [1] => test 1
I have an array of arrays, like so: [['1','2'],['a','b'],['x','y']] I need to combine those

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.