I have two arrays, $full_list and $only_titles with matching value based on first key.
$full_list:
Array
(
[0] => Array
(
[0] => samsung-a40
[1] => Samsung A40 Phone
[2] =>
[3] => 21
[4] => 334234
[5] => 0
)
[1] => Array
(
[0] => samsung-a72
[1] => Galaxy A72 Phone
[2] =>
[3] => 230
[4] => 239049
[5] => 0
)
[2] => Array
(
[0] => lg-k61
[1] => LG K61 Phone
[2] =>
[3] => 22
[4] => 249582
[5] => 0
)
etc...
$only_titles:
Array
(
[0] => Array
(
[0] => samsung-a40
[1] => Black Phone Case For Samsung A40
)
[1] => Array
(
[0] => lg-k61
[1] => Red Case LG K61 Phone
)
[2] => Array
(
[0] => samsung-a72
[1] => Folding Phone Case for Galaxy A72 Phone
)
etc...
I want to take value from second key from $only_title array (its basicaly long product title) and replace it in the $full_list array:
$final_result:
Array
(
[0] => Array
(
[0] => samsung-a40
[1] => Black Phone Case For Samsung A40 // title from $only_titles
[2] =>
[3] => 21
[4] => 334234
[5] => 0
)
[1] => Array
(
[0] => samsung-a72
[1] => Folding Phone Case for Galaxy A72 Phone // title from $only_titles
[2] =>
[3] => 230
[4] => 239049
[5] => 0
)
[2] => Array
(
[0] => lg-k61
[1] => Red Case LG K61 Phone // title from $only_titles
[2] =>
[3] => 22
[4] => 249582
[5] => 0
)
etc...
I have tried array_replace_recursive(), but the problem with this is that it expects that the order of subarrays are the same. But as you can see in both arrays the second subarrays dont match. With array_replace_recursive() i get the second subarray wrong:
[1] => Array
(
[0] => samsung-a72
[1] => Red Case LG K61 Phone // this is wrong
[2] =>
[3] => 230
[4] => 239049
[5] => 0
)
How can I check if values from first key match?