-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 :)

2
  • 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. Commented Apr 16, 2014 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... Commented Apr 16, 2014 at 14:46

1 Answer 1

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);

?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.