I have the following input array, I would like to flatten the array to evaluate true or false conditions.
array (
'all' =>
array (
'0' =>
array (
0 => 'true')
'1' =>
array (
0 => 'true')
'2' =>
array (
0 => 'true')
),
array (
'any' =>
array (
'0' =>
array (
0 => 'true')
'1' =>
array (
0 => 'false')
))
)
I would like to get the output in the following format.
Output Array:
all =>(
true,
true,
true,
any => (true,
false)
)
There are many PHP built in functions available to sort out your issue.
You can use array_values like below:
And if you're using PHP 5.5+, you can use array_column() like below:
You can also try
array_flatten
orarray_map
for lower PHP versions.Example with
array_values
: