I not find something similar on Stackoweflow and need help.
I have an array like this:
$array = array(
array(
1 => false,
2 => false,
3 => true,
4 => true,
5 => false,
6 => false,
7 => false,
8 => false,
9 => false,
10 => false,
),
array(
1 => false,
2 => false,
3 => false,
4 => true,
5 => true,
6 => true,
7 => true,
8 => false,
9 => false,
10 => false,
),
array(
1 => false,
2 => false,
3 => false,
4 => false,
5 => false,
6 => false,
7 => false,
8 => false,
9 => true,
10 => true,
),
);
and I need result like this:
array(
1 => false,
2 => false,
3 => true,
4 => true,
5 => true,
6 => true,
7 => true,
8 => false,
9 => true,
10 => true,
)
Generaly this is one calendar functionality and I counting fom 1-31 but this is not realy important.
I try with call_user_func_array
and array_merge_recursive
, try some custom foreach
but I stack here in logic.
Like you see, this is NOT 2 multidimensional arrays. This is only one multidimensinal array and I need to transform it in one simple array like example above.
Boolean true
is most important and need to be on the right place like value.
EDIT:
Thanks to @MacBooc i get working results:
$r = array();
foreach($array as $k=>$a){
foreach($a as $n=>$b){
if($b===true)
$r[$n] = $b;
}
}
$result = array_replace($array[0], $r);
ksort($result);
var_dump($result);
NOTE:
-Admins, please read questions carefully before you close or downvote something.