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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:39:19+00:00 2026-05-27T18:39:19+00:00

Given the following array $a = array( ‘a’ => ‘0’, ‘b’ => ‘1’, ‘c’

  • 0

Given the following array

$a = array(
    'a' => '0',
    'b' => '1',
    'c' => '2',
    'push' => array(
         'd' => '0',
         'e' => '1',
         'here' => array()
    )
);

And the following set of loops:

// First level
foreach($a as $key=>$value):

     if($key=='push'):

        //Second level
        foreach($value as $key_=>$value_):

             if($key_=='here'):

              // If this key is found then do some stuff here and get another as a result array
              $thirdArray = array(12, 13, 15);

              // Then, I am looking to push this third array from within this loop 
              // Obviously, it should be placed inside this particular key of the array
              // I am trying something like below which doesn't work

              //array_push($value_, $thirdArray);

              endif;

         endforeach;

     endif;

 endforeach;

/* The output of printing my array should be

  'a' => 'A',
  'b' => 'B',
  'c' => 'C',
      'push' => array(
            'd' => '0',
            'e' => '1',
            'here' => array(

                     array(12, 13, 15)

             )


  */

This is giving me a big headache… and can’t seem to find a solution.. Many thanks for your help 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-05-27T18:39:20+00:00Added an answer on May 27, 2026 at 6:39 pm
    foreach($value as $key_=>$value_):
      if($key_=='here'):
        $thirdArray = array(12, 13, 15);
        $a['push']['here'][] = $thirdArray;
      endif;
    endforeach;
    

    or

    foreach($value as $key_=>$value_):
      if($key_=='here'):
        $thirdArray = array(12, 13, 15);
        $a[$key][$key_][] = $thirdArray;
      endif;
    endforeach;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following Ruby statements: (Read input and store each word in array removing spaces
Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>
Given the following: declare @a table ( pkid int, value int ) declare @b
Given the following two indexed arrays: $a = array('a', 'b', 'c'); $b = array('red',
Given the following array array( 0 => array( 'id' => '54'), 1 => array(
Can you help me out with this question please. Question: Given the following array
Given the following array: Array ( [143] => Car #1 [144] => Car #2
Given the following PHP array: Array ( [0] => Array ( [name] => Restaurant
Given the following NumPy array, > a = array([[1, 2, 3, 4, 5], [1,

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.