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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:46:48+00:00 2026-05-31T15:46:48+00:00

I am trying to create a multi dimensional array using $whole_array=array($case_id1,$case_name1,$case_status1); (these are variables

  • 0

I am trying to create a multi dimensional array using

$whole_array=array($case_id1,$case_name1,$case_status1);

(these are variables of my code)

But when I am trying to print that array outside the loop it is showing only last value as it is getting overwritten in the loop.

I know how to initialize outside but I have no clue how to use that created array within the code without using “array” keyword. Can anyone please enlighten me with this?

I am attaching the code for convenience:

<?php

$case_id1=array();
$case_name1=array();
$case_status1=array();
$case_id2=array();
$case_name2=array();
$case_status2=array();
$case_message1=array();
$case_message2=array();
$whole_array=array($case_id1,$case_name1,$case_status1);

$k=0;
$l=0;

while($k<count($case1) && $l<count($case2))
{
    if($case1[$k]['case_id']==$case2[$l]['case_id'])
    {
        if($case1[$k]['status']<>$case2[$l]['status'])
        {
            $case_id1["case_id"]=$case1[$k]['case_id'];
            $case_name1["case_name"]=$case1[$k]['case_name'];
            $case_status1["case_status"]=$case1[$k]['status'];
            $whole_array=array($case_id1,$case_name1,$case_status1);//PROBLEM
            //var_dump($whole_array);

            if($case1[$k]['status']=='FAILURE' || $case1[$k]['status']=='ERROR')
            {
                $case_message1[]=$case1[$k]['message'];
                //echo $case1[$k]['status']." message ".$case1[$k]['message'];
                //echo "</br>";
                //echo "do";

            }

            $case_id2[]=$case2[$l]['case_id'];
            $case_name2[]=$case1[$l]['case_name'];
            $case_status2[]=$case2[$l]['status'];

            if($case2[$l]['status']=='FAILURE' || $case2[$l]['status']=='ERROR')
            {
                $case_message2[]=$case2[$l]['message'];
                //echo $case2[$l]['status']." message: ".$case2[$l]['message'];
                //echo "</br>";
                //echo "do nothing";

            }
        }

    }
    $k++;
    $l++;
}
/*

    echo "test plan: ".$results_2[$c][$i['test_plan']]['test_plan'];
    echo "</br>";
    echo "result plan id 1: ".$results_1[$c][$i['test_plan']]['result'];
    echo "</br>";
    echo "result plan id 2 : ".$results_2[$c][$i['test_plan']]['result'];
    echo "</br>";
*/

?>
  • 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-31T15:46:50+00:00Added an answer on May 31, 2026 at 3:46 pm

    You’re looking for either array_push() or the following notation:

    $whole_array[] = array($case_id1,$case_name1,$case_status1);
    

    or

    array_push($whole_array, array($case_id1,$case_name1,$case_status1));
    

    Note: If you use array_push() to add one element to the array it’s better to use $array[] = because in that way there is no overhead of calling a function.

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

Sidebar

Related Questions

I am trying to create a multi dimensional array using this syntax: $x[1] =
I am trying to create a multi-dimensional array whose parts are determined by a
I'm trying to create a multidimentional int array with the following function code: int
I have a multi-dimensional array called my_ids_and_names It should probably be a hash but
I have a multi-dimensional array that I am trying to feed into difflib.get_close_matches() .
I am trying to comprehend how I can create multi-dimensional NSMutable arrays in general.
I am trying to create a multi project template. I wish the sub projects
I am trying to create a multi level navigation menu with css. I guess
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5

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.