I have a multidimensional array-like below how can I convert
array(2) {
["category"]=>
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
["post_tag"]=>
array(8) {
[0]=>
array(0) {
}
[1]=>
array(2) {
[0]=>
string(1) "9"
[1]=>
string(1) "5"
}
[2]=>
array(2) {
[0]=>
string(1) "6"
[1]=>
string(2) "11"
}
[3]=>
array(0) {
}
[4]=>
array(0) {
}
[5]=>
array(0) {
}
[6]=>
array(2) {
[0]=>
string(1) "9"
[1]=>
string(1) "5"
}
[7]=>
array(2) {
[0]=>
string(1) "6"
[1]=>
string(2) "11"
}
}
}
To like this
array(2){
array(
'taxonomy'=> 'category',
'data'=> "", //empty because nothing in it
)
array(
'taxonomy => 'post_tag',
'data => array( 9,5,6,11), //duplicates removed
)
}
I have tried with multiple foreach() loop but couldn't do it. using array_filter() , array_merge() is not working out .
Is there any way to get to a format like that?
var_export()of your array people can check their answer easier as that output is easy to pop into a piece of test codevar_export($array)