fork download
  1. <?php
  2.  
  3. $arr = [
  4. 7100 => [
  5. 'qtdadulto' => 0,
  6. 'qtdpintoumdia' => 0,
  7. 'qtdovosferteis' =>0
  8. ],
  9. 7108 => [
  10. 'qtdadulto' => 0,
  11. 'qtdpintoumdia' =>0,
  12. 'qtdovosferteis' => 0
  13. ],
  14. 7110 => [
  15. 'qtdadulto' => 0,
  16. 'qtdpintoumdia' => 0,
  17. 'qtdovosferteis' => 0
  18. ]
  19. ];
  20.  
  21. $arr2 = [7100 => 1, 7108 => 200, 7110 => 500, 800 => 99];
  22.  
  23.  
  24. foreach($arr as $k => $v){
  25. if(isset($arr2[$k])){
  26. $arr[$k]['nome'] = $arr2[$k];
  27. }
  28. }
  29.  
  30. print_r($arr);
  31.  
  32.  
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
Array
(
    [7100] => Array
        (
            [qtdadulto] => 0
            [qtdpintoumdia] => 0
            [qtdovosferteis] => 0
            [nome] => 1
        )

    [7108] => Array
        (
            [qtdadulto] => 0
            [qtdpintoumdia] => 0
            [qtdovosferteis] => 0
            [nome] => 200
        )

    [7110] => Array
        (
            [qtdadulto] => 0
            [qtdpintoumdia] => 0
            [qtdovosferteis] => 0
            [nome] => 500
        )

)