I am extracting duplicated values from nested arrays. I would like to delete these extraceted items from the $bigarray. would you give me some ideas...?
$bigarray = array(
"430" => array('milk', 'turky', 'apple'),
"433" => array('milk', 'apple', 'orange', 'england'),
"444" => array('milk', 'apple', 'orange', 'spain')
);
$intersected = null;
foreach ($bigarray as $arr) {
$intersected = $intersected ? array_intersect($arr, $intersected) : $arr;
if (!$intersected) {
break; // no reason to continue
}
}
foreach ($intersected as $inter){
foreach ($bigarray as $arr) {
foreach ($arr as $value=>$key) {
if ($key == $inter){
unset($arr[$value]);
}
}
//print_r($arr);
}
}
print_r($bigarray );
$intersectedafter the loop exits), you take that result and go back to the original arrays and delete those values.$valuein that context is a COPY of whatever's in the array. You need to refer to the original array:unset($clauses[$key1][$key2]).