want to normalize an array and need help.
Array i have:
$myArr = array(
array(
array(
array("id" => 1)
)
),
array("id" => 2),
array("id" => 3),
array(
array(
"id" => 4)
)
);
Array i want to have:
$myArr = array(
array("id" => 1),
array("id" => 2),
array("id" => 3),
array("id" => 4)
);
My idea to solve that prob is calling a recursive method, which is not working yet:
function myRecArrFunc(&myarr){
$output = [];
foreach{$myarr as $v}{
if(!isset{$v["id"]){
$output[] = myRecArrFunc($v);
} else{
$output[] = $v;
}
}
return $output
}
Currently the output of the function is the same as the input. Someone has an idea what have to be done?
myarr, a loose brace, missing parentheses around function argument forisset, a missing semi-colon near the end....