3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr0 = [ [ 'id' => 107, 'name' => 'Sarah', 'msgSinleer' => 2, 'subject' => [], ], [ 'id' => 110, 'name' => 'Manuela', 'msgSinleer' => 27, 'subject' => [], ], ]; $arr1 = [ [ 'id' => 110, 'Cliente' => 'Alexis', 'body' => 'Hola', 'fecha' => '06/01/2021 11:35 AM', 'status' => 1, 'tiempoSinLeer' => '15 01:00', ], [ 'id' => 110, 'Cliente' => 'Alexis', 'body' => 'Hola asd asdasd', 'fecha' => '05/26/2021 11:35 AM', 'status' => 1, 'tiempoSinLeer' => '21 01:00', ], [ 'id' => 107, 'Cliente' => 'George', 'body' => 'vhgfshsgf', 'fecha' => '06/15/2021 03:48 PM', 'status' => 1, 'tiempoSinLeer' => '1 08:48', ], ]; foreach($arr0 as $key => $record) { foreach($arr1 as $subject) { if($record['id'] === $subject['id']) $arr0[$key]['subject'][] = $subject; } } echo '<pre>'; print_r($arr0); echo '</pre>';

preferences:
13.67 ms | 404 KiB | 5 Q