How can I calculate how many of the elements in a array like this have a non-empty data field, in percetanges?
[elements] => Array
( [abc] => Object
(
[data] => Array ([0] => 'something')
)
[def] => Object
(
[data] => Array ()
)
...
In this exemple it would be 50% because there are 2 elements, and 1 of them has something in data…
$percent = count(array_filter($elements, function($ele){return !empty($ele->data);})) / count($elements) *100;