samedi 27 juin 2020

how to add value from another array?

I have 2 array and this array structur look like.

array 1:

array:21 [▼
  8 => 5.2611505021202
  21 => 1.9708761602636
  4 => 1.9691954688805
] 

array 2:

array:21 [▼
  8 => array:2 [▼
    "id" => 10
    "details" => "Intel Core i5 4GB 1TB"
  ]
  21 => array:2 [▼
    "id" => 14
    "details" => "Intel Core i5 8GB 2TB SSD Touch Bar"
  ]
  4 => array:2 [▼
    "id" => 4
    "details" => "Intel Core i7-8700 GTX1060 8GB 1TB SSD Win10"
  ]
]

the problem is, how can u combine that array and make new array like this :

array:21 [▼
  8 => array:2 [▼
    "id" => 10
    "details" => "Intel Core i5 4GB 1TB"
    "score" => 5.2611505021202 //value from array 1 and input the value to same index [8] -> [8]
  ]
  21 => array:2 [▼
    "id" => 14
    "details" => "Intel Core i5 8GB 2TB SSD Touch Bar"
    "score" => 1.9708761602636 //value from array 1 and input the value to same index [21] -> [21]
  ]
  4 => array:2 [▼
    "id" => 4
    "details" => "Intel Core i7-8700 GTX1060 8GB 1TB SSD Win10"
    "score" => 1.9691954688805 //value from array 1 and input the value to same index [4] -> [4]
  ]
]

is that possible ?, im newb very grateful if someone helps. sorry for my broken english.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2VoO8ep
via IFTTT

Aucun commentaire:

Enregistrer un commentaire