I'm trying to compare two arrays, and extract some info of one of them and store it at another array (3rd). The structure of these two arrays looks like this:
Array(
[0] => stdClass Object
    (
        [Id] => 123
        [Size] => small
        [Color] => yellow
    )
[1] => stdClass Object
    (
        [Id] => 456
        [Size] => large
        [Color] => red
    )
[2] => stdClass Object
    (
        [Id] => 789
        [Size] => medium
        [Color] => blue
    )
)
Array
(
[0] => stdClass Object
    (
        [Id] => 456
        [Size] => large
        [Color] => red
        [Available] => true
    )
[1] => stdClass Object
    (
        [Id] => 123
        [Size] => small
        [Available] => false
    )
[2] => stdClass Object
    (
        [Id] => 789
        [Size] => medium
        [Color] => blue
        [Available] => true
    )
)
In the example, I need to store the property "available" only if the ID of these arrays are equal.
What I tried to do:
for (var $i = 0; $i < count($arrayA); $i++) {
    if ($ArrayA[$i]->Id == $arrayB[$i]->Id) {
        $getAvailable = $arrayB[$i]->Available;
    }
}
The problem:
Since we can have the situation where the property id in array A, position 0 is in a different position in array B, which can have a different structure, I have no idea how can I access the information I need (available), from one array comparing the ids of ArrayB and ArrayA.
I am sorry if I didn’t explain it better, because it’s a bit hard to put in words this situation, but let me know if you have any questions, and please, help me finding a solution :)
Desired array should look like this:
Array(
[0] => stdClass Object
(
    [Id] => 123
    [Size] => small
    [Color] => yellow
    [Available] => false
)
 
     
     
    