我想根据integratedSecurity=true
my_主阵列: sub_id等于8 sub_id等于8 sub_id等于9 sub_id等于9 sub_id等于9
结果应该是,第一个数组:
sub_id
第二个数组
sub_id equal 8
sub_id equal 8
答案 0 :(得分:0)
使用array_filter()与您的条件匹配的回调
$key = 8;
$first = array_filter(
$originalArray,
function($value) use ($key) {
return $value['sub_products_id'] == $key;
}
);
$key = 9;
$second = array_filter(
$originalArray,
function($value) use ($key) {
return $value['sub_products_id'] == $key;
}
);
答案 1 :(得分:0)
$arrayA = [];
$arrayB = [];
array_map(function($value) use (&$arrayA, &$arrayB) {
if ($value['sub_products_id'] == 8) {
$arrayA[] = $value;
} else {
$arrayB[] = $value;
}
}, $originalArray);