-1

Hi i have an array like this

Array
(
    [0] => Array
        (
            [employeename] => abc

        )

    [1] => Array
        (            
            [employeename] => def


        )

)

Array
(
    [0] => 1
    [1] => 3
)

I need the second array value to be set in first array like this

Array
    (
        [0] => Array
            (
                [employeename] => abc
                [othername] => 1

            )

        [1] => Array
            (            
                [employeename] => def
                [othername] => 3


            )

    )

Any Help Will be appreciated , Thanks In Advance :)

ManoharSingh
  • 487
  • 4
  • 27
  • 3
    Questions asking for code must **demonstrate a minimal understanding of the problem being solved**. Include attempted solutions, why they didn't work, and the expected results. See also: [Stack Overflow question checklist](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist). – John Conde Apr 16 '14 at 14:33
  • 1
    John, I see the original, I see the wanted result, and I see someone who doesn't have a clue on how to solve this, but that's not a reason to bash this fellow... Hence the answer given by @PrasanthBendra, which is the perfect solution. This guy came here with a problem and was looking for an answer. I see a lot of moderators take their job way too seriously. OS is here to help (and doing a great job at that!), please don't loose focus on why this page is here... Now I do agree with the possible duplicate report, 'cause it is a duplicate... – patrick Apr 16 '14 at 14:46

1 Answers1

1

Try this :

<?php
$array1 = array(array("employeename" => "abc"),
                array("employeename" => "def")
          );
$array2 = array(1,3);

foreach($array1 as $key=>$val){
    $array1[$key]["othername"] = $array2[$key];
}

echo "<pre>";
print_r($array1);

?>
Prasanth Bendra
  • 31,145
  • 9
  • 53
  • 73