Creating a mutlidimensional array in PHP
<p>I am trying to create a multi dimensional array using </p>

<pre><code>$whole_array=array($case_id1,$case_name1,$case_status1);
</code></pre>

<p>(these are variables of my code)</p>

<p>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.</p>

<p>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?</p>

<p>I am attaching the code for convenience:</p>

<pre><code>&lt;?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&lt;count($case1) &amp;&amp; $l&lt;count($case2))
{
    if($case1[$k]['case_id']==$case2[$l]['case_id'])
    {
        if($case1[$k]['status']&lt;&gt;$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 "&lt;/br&gt;";
                //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 "&lt;/br&gt;";
                //echo "do nothing";

            }
        }

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

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

?&gt;
</code></pre>
