how to create multidimensional array using a foreach loop in php?
<p>When I take the form values in array</p>

<pre><code>$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$job   = $_POST['job'];
$desc  = $_POST['desc'];
$photo = $_POST['image_url'];

$memberdata = Array(
          'first_name' =&gt; $fname,
          'last_name' =&gt; $lname,
          'job' =&gt; $job,
          'desc' =&gt; $desc,
          'image_url' =&gt; $photo
          );
</code></pre>

<p>and echoing this array it prints like below. 
How should the code be modified to achieve the goal?
Is there any other ways to get results what I want?
Member forms are dynamically generated using jquery.
And I want to get member vise array that I mentioned below. </p>

<pre><code>Array
(
    [first_name] =&gt; Array
        (
            [0] =&gt; Member1
            [1] =&gt; Member2
            [2] =&gt; Member3
        )

    [last_name] =&gt; Array
        (
            [0] =&gt; Member1
            [1] =&gt; Member2
            [2] =&gt; Member3
        )

    [job] =&gt; Array
        (
            [0] =&gt; President
            [1] =&gt; MD
            [2] =&gt; CEO
        )

    [desc] =&gt; Array
        (
            [0] =&gt; President of
            [1] =&gt; MD of
            [2] =&gt; CEO of
        )

    [image_url] =&gt; Array
        (
            [0] =&gt; 
            [1] =&gt; 
            [2] =&gt; 
        )

)
</code></pre>

<p>How to make particular array from above array?
How should the code be modified to achieve the goal?
 This is what i want. </p>

<pre><code> Array
(
   [0] =&gt; Array
   (
      [first_name] =&gt; Member1
      [last_name] =&gt; Member1
      [job] =&gt; President
      [desc] =&gt; President of
      [image_url] =&gt;
   )

   [1] =&gt; Array
   (
      [first_name] =&gt; Member2
      [last_name] =&gt; Member2
      [job] =&gt; MD
      [desc] =&gt; MD of
      [image_url] =&gt;
   )

   [2] =&gt; Array
   (
      [first_name] =&gt; Member3
      [last_name] =&gt; Member3
      [job] =&gt; CEO 
      [desc] =&gt; CEO of
      [image_url] =&gt;
   )
)
</code></pre>