hello,
i have array

Array
(
    [certificate] => Array
        (
            ['name'] => Array
                (
                    [1] => 11
                    [2] => 22
                    [3] => 33
                    [5] => 55
                    [6] => 66
                )

            ['date'] => Array
                (
                    [1] => 1111
                    [2] => 2222
                    [3] => 3333
                    [5] => 5555
                    [6] => 6666
                )
)

I want to make echo name=>1 value with date=>1 value.

though,Indexes of both array are same but are not in serial.
like in above case we have missed 4th index.
so how to merger these two?

Your question is not terribly clear but are you trying to do something like this?

$names = $certs['name'];
$dates = $certs['date'];

$keys = array_keys($names);

$out = '';
foreach($keys as $key)
{
 if (!array_key_exists($dates,$key)) continue;
 $out .= $names[$key].'='.$dates[$key];
}

echo $out;

Your requirment can be achieved by a foreach loop. I just used an echo for the merge, but u can insert the values to another array as you wish.

<?php
    $arr = Array
    (
        "certificate" => Array
        (
            "name" => Array
            (
                1 => 11,
                2 => 22,
                3 => 33,
                5 => 55,
                6 => 66
            ),
            "date" => Array
            (
                1 => 1111,
                2 => 2222,
                3 => 3333,
                5 => 5555,
                6 => 6666
            )
        )
    );

    foreach($arr["certificate"]["name"] as $key => $value)
    {
        echo $arr["certificate"]["name"][$key] ." - ". $arr["certificate"]["date"][$key] . "<br/>";
    }
?>

Hello niranga,
Actually above this is print_r($_POST) value of form.

so it is not like

 $arr = Array
(
"certificate" => Array
(
"name" => Array
(

but ots like

Array
(
[certificate] => Array
(
['name'] => Array
(

for for applying for loop for key value paire is not applicable here.
it says
"Undefined index: name " for

foreach($_POST["certificate"]["name"] as $key => $value)

Hi Priti_P
The print_r displays the elements in your array in the given format, but its just for display. Try printing my variable, i.e. $arr using print_r. It gives you the same output. Will you be able to post the var_dump($_POST) result?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.