Код: Выделить всё
Array
(
[25] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
[26] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
[36] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
)
Код: Выделить всё
Array
(
[25] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
[26] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
[30] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
)
Таким образом, возвращаемый массив должен выглядеть так (как я уже сказал, [25] и [26] содержатся в оба массива, поэтому они возвращаются):
Код: Выделить всё
Array
(
[25] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
[26] => Array
(
[items_to_give] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
[items_to_get] => Array
(
[0] => Array
(
[xx] => xx
[xx] => xx
)
)
)
)
Код: Выделить всё
$result = array_map("unserialize", array_intersect($this->serialize_array_values($array1),$this->serialize_array_values($array2)));
function serialize_array_values($arr){
foreach($arr as $key=>$val){
sort($val);
$arr[$key]=serialize($val);
}
return $arr;
}
Я хочу, чтобы массив остался прежним он, когда возвращается, это означает, что мне нужны [items_to_give] и [items_to_get] вместо индексов [0] и [1]
Какие еще возможны решения? Спасибо за решения.
Подробнее здесь: https://stackoverflow.com/questions/324 ... nal-arrays