I have an array, and would like to get all the values like this [*][place], without duplicate results. The output should be looking like this :
Sønderjylland Nordjylland Sjælland
Array
(
[0] => Array
(
[place] => Sønderjylland
[active] => Lagerarbejde
[num] => 123
)
[1] => Array
(
[place] => Nordjylland
[active] => Tømrer
[num] => 124
)
[2] => Array
(
[place] => Sønderjylland
[active] => Klejnsmed
[num] => 125
)
[3] => Array
(
[place] => Sjælland
[active] => Elektriker
[num] => 126
)
)
You can use array_column, array_unique, array_filter, implode together.
echo implode(' ', array_filter(array_unique(array_column($yourArray, 'place'))));
array_column is supported for (PHP 5 >= 5.5.0, PHP 7)
If you are using older versions then a loop would help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With