Hi I'm trying to fill this array
Array
(
[0] => Array
(
[id] => 107
[name] => Sara
[msgSinleer] => 2
[subject] => Array
(
)
)
[1] => Array
(
[id] => 110
[name] => Manuela
[msgSinleer] => 27
[subject] => Array
(
)
)
)
with the values of this array if one of the ID match
Array
(
[0] => Array
(
[id] => 110
[Cliente] => Alexis
[body] => Hola
[fecha] => 06/01/2021 11:35 AM
[status] => 1
[tiempoSinLeer] => 15 01:00
)
[1] => Array
(
[id] => 110
[Cliente] => Alexis
[body] => Hola asd asdasd
[fecha] => 05/26/2021 11:35 AM
[status] => 1
[tiempoSinLeer] => 21 01:00
)
[2] => Array
(
[id] => 107
[Cliente] => George
[body] => vhgfshsgf
[fecha] => 06/15/2021 03:48 PM
[status] => 1
[tiempoSinLeer] => 1 08:48
)
)
So I'm trying to show the result in this way but I don't know how to do it, I tried some others methods like array_search, array_in and a foreach inside another foreach trying to see if inside can do an if statement but it doesn't work.
Array
(
[0] => Array
(
[id] => 107
[name] => Sara
[msgSinleer] => 2
[subject] => Array
(
[Cliente] => George
[body] => vhgfshsgf
[fecha] => 06/15/2021 03:48 PM
[status] => 1
[tiempoSinLeer] => 1 08:48
)
)
[1] => Array
(
[id] => 110
[name] => Manuela
[msgSinleer] => 27
[subject] => Array
(
[Cliente] => Alexis
[body] => Hola
[fecha] => 06/01/2021 11:35 AM
[status] => 1
[tiempoSinLeer] => 15 01:00
),
(
[Cliente] => Alexis
[body] => Hola asd asdasd
[fecha] => 05/26/2021 11:35 AM
[status] => 1
[tiempoSinLeer] => 21 01:00
)
)
)
And this is the code that I have that bring me the arrays
foreach ($query2 as $key2) {
$result2[] = $key2;
}
foreach ($query as $value) {
array_push($result , array(
"id" => $value['id'],
"name" => $value['name'],
"msgSinLeer" => $value['msgSinleer'],
"subject" => array(),
));
}
print_r ($result);
print_r ($result2);
I'm new in php so if someone can help me I will appreciate