Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
create array from multiple arrays & submit in mysql table

I am trying to fetch values from few - dynamically created HTML FORM & in action file, i am grabbing those values via $_POST. Please consider humbly, that i am using array in dynamic inputs like :

<input name="array1[]" />
<input name="array2[]" />
<input name="array3[]" />

So, that, after FORM SUBMIT, in action file, its giving :

         $a =    Array
        (
            [0] => 04/21/2017
            [1] => 04/19/2017
            [2] => 04/25/2017
            [3] => 04/25/2017
            [4] => 10/25/2017
        )

    $b=    Array
        (
            [0] => 11
            [1] => 34
            [2] => 12
            [3] => 12
            [4] => 2
        )

      $c=  Array
        (
            [0] => fghgthg
            [1] => ggfg
            [2] => fgfgfdgf
            [3] => fgfdgdgfgdh
            [4] => rgrgfgf
        )

Now, m having troubles in arranging this way :

$FinalArray = array(

array($a[0], $b[0], $c[0]),
array($a[1], $b[1], $c[1]),
array($a[2], $b[2], $c[2]),
array($a[3], $b[3], $c[3]),
......last line without comma

  );

And submitting in mysql table, so that i can easily retrieve it like :

step-1 : $FinalArray[0];
step-2 : $FinalArray[1]; 
.......goes on

Thanks, for help, in Advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This simple foreach help you in achieving your desired output.

Try this code snippet here

<?php

ini_set('display_errors', 1);

$a = Array
    (
    0 => "04/21/2017",
    1 => "04/19/2017",
    2 => "04/25/2017",
    3 => '04/25/2017',
    4 => "10/25/2017"
);

$b = Array
    (
    0 => 11,
    1 => 34,
    2 => 12,
    3 => 12,
    4 => 2
);

$c = Array
    (
    0 => "fghgthg",
    1 => "ggfg",
    2 => "fgfgfdgf",
    3 => "fgfdgdgfgdh",
    4 => "rgrgfgf",
);
$result=array();
foreach($a as $key => $value)
{
    $result[]=array($value,$b[$key],$c[$key]);
}
print_r($result);

Output:

Array
(
    [0] => Array
        (
            [0] => 04/21/2017
            [1] => 11
            [2] => fghgthg
        )

    [1] => Array
        (
            [0] => 04/19/2017
            [1] => 34
            [2] => ggfg
        )

    [2] => Array
        (
            [0] => 04/25/2017
            [1] => 12
            [2] => fgfgfdgf
        )

    [3] => Array
        (
            [0] => 04/25/2017
            [1] => 12
            [2] => fgfdgdgfgdh
        )

    [4] => Array
        (
            [0] => 10/25/2017
            [1] => 2
            [2] => rgrgfgf
        )

)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!