According to the value 5 4 1 contained in array two, unset the above array one without the key 5 4 1 to find the simplest way to write it. ha
// 数组一
array(6) {
[1] => string(12) "伊凡木门"
[2] => string(12) "梦天木门"
[3] => string(15) "大自然地板"
[4] => string(12) "尚品宅配"
[5] => string(15) "德国都芳漆"
[6] => string(12) "左右沙发"
}
数组二
array(3) {
[0] => int(5)
[1] => int(4)
[2] => int(1)
}
I finally solved it with the following method. If the masters have a better way of writing, please feel free to enlighten me
You can use the functions of the array_diff series to operate. You can decide by yourself whether to use array_diff_key or assoc for the specific business.
According to the value 5 4 1 contained in array 2, find the simplest way to write the unset of the above array 1 which does not exist and the key is not 5 4 1. Ha
means I don’t understand
Create a new array to store the values you want to retain. Then loop through array two, and then use the array_push function to push the values to be retained in array one into the newly created array.
First flip array 2, and then find the intersection. I think your solution is the correct one
You can learn about the array_slice function