There are two arrays:
Array ( [0] => Array ( [y] => 67 [product_id] => 0 [product_type] => 3 ) [1] => Array ( [y] => 30 [product_id] => 3 [product_type] => 2 ) [2] => Array ( [y] => 17 [product_id] => 2 [product_type] => 2 ) [3] => Array ( [y] => 23 [product_id] => 1 [product_type] => 2 ) ) Second array
Array ( [0] => Array ( [title] => Title 1 [id] => 1 ) [1] => Array ( [title] => Title 2 [id] => 3 ) [2] => Array ( [title] => Title 3 [id] => 2 ) ) I need to check if the [product_id] of the first array matches the [id] of the second array, then add [type] => [id] [title] - the second array to the first array.
I do this as follows: 1. I count the length of the array 2. 2. I run for while $ i <Array length 2 3. Compare $ i [product_id] and $ i [id] 4. If it is the same, I write down the value. It works, but it works only 3 times, because the second array is 3 long, and the first one is longer, therefore it does not calculate everything. How to be in this case?