I have a piece of multidimensional array output like this:
Array
(
[0] => Array
(
[item] => null
[count] => 0
[child] => Array
(
[Dagadu Bocah] => Array
(
[item] => Dagadu Bocah
[count] => 47
[child] => Array
(
[HirukPikuk] => Array
(
[item] => HirukPikuk
[count] => 5
[child] => Array
(
[DGD] => Array
(
[item] => DGD
[count] => 1
[child] =>
)
)
)
In my expectations, I can use the unset function in the foreach loop to delete each array that has 3 keys, namely 'item', 'count' and 'child' so that it produces an array like this:
Array
(
[0] => ([Dagadu Bocah] =>Array([HirukPikuk] =>Array([DGD])
)
this is my code and does not meet my expectations:
public function conditionalPatternBase($a){
{
foreach($a as $key => $value){
foreach($value['child'] as $key1 => $value1){
if(is_array($value1['child'])){
foreach($value1['child'] as $value2){
unset($value2);
if(is_array($value2['child'])){
foreach($value2['child'] as $value3){
unset($value3);
if(is_array($value3['child'])){
foreach($value3['child'] as $value4){
unset($value4);
if(is_array($value4['child'])){
foreach($value4['child'] as $value5){
unset($value5);
}
}
}
}
}
}
}
}
}
}
}
}
can anyone help?