Adding key=>value pair to existing array with condition

Viewed 32443

Im trying to add a key=>value to a existing array with a specific value.

Im basically looping through a associative array and i want to add a key=>value foreach array that has a specific id:

ex:

[0] => Array
    (
        [id] => 1
        [blah] => value2

    )

[1] => Array
    (
        [id] => 1
        [blah] => value2
    )

I want to do it so that while

foreach ($array as $arr) {

     while $arr['id']==$some_id {

            $array['new_key'] .=$some value
            then do a array_push
      }    
}

so $some_value is going to be associated with the specific id.

3 Answers
Related