I'm trying to count the number of variables that are set to 'yes' using PHP and then output the count.
So for example, I have the following variables:
$facebook = $params->get('facebook');
$twitter = $params->get('twitter');
$email = $params->get('email');
$pinterest = $params->get('pinterest');
$google = $params->get('google');
and if they're all set to 'yes', then there would be a count of 5, using this method:
<?php
$social = array('facebook', 'twitter', 'email', 'pinterest', 'google');
echo count($social); // output 5
?>
However, if some are set to 'no' how can I then count all of the ones which are set to 'yes'?