I'm trying to separate the "TID" in an array from these multiple arrays but I couldn't find the efficient solution.
I've the following type of arrays in one variable:
Array
(
[0] => Array
(
[tid] => 168
)
)
Array
(
[0] => Array
(
[target_id] => 14
)
[1] => Array
(
[target_id] => 15
)
[2] => Array
(
[target_id] => 37
)
)
Array
(
)
Array
(
[0] => Array
(
[target_id] => 36
)
)
Array
(
[0] => Array
(
[target_id] => 14
)
[1] => Array
(
[target_id] => 15
)
)
Array
(
[0] => Array
(
[target_id] => 36
)
)
Array
(
[0] => Array
(
[tid] => 168
)
[1] => Array
(
[tid] => 167
)
)
These values are in one variable and there can be unlimited arrays.
And Expected Output:
Array
(
[0] => Array
(
[tid] => 168
)
[1] => Array
(
[tid] => 168
)
[2] => Array
(
[tid] => 167
)
)
You are searching for array_column.
Here is the syntax
Description
Example :
OUTPUT :
If you have more arrays,
then you can do array_merge.
OUTPUT :