I have the following array of client data:
Array
(
[0] => Array
(
[client_id] => 3680
[firstname] => Brian
[surname] => May
[company] =>
)
[1] => Array
(
[client_id] => 3688
[firstname] => Freddie
[surname] => Mercury
[company] =>
)
[2] => Array
(
[client_id] => 3694
[firstname] => Roger
[surname] => Taylor
[company] =>
)
)
I want to display this in a table however if any element is null in ALL cases (such as “company” in this example) I don’t want to show that column in the table.
Can anyone suggest how this may be done without first looping through the whole array?
You cant avoid doing loopings in this case, so the best approach I can think about your case is:
The $empty_columns will return one array with the columns where all the values are NULL;
In this example:
Just check this array before print your columns.