mercredi 20 décembre 2017

If empty, how can I echo 0

If the below do not have a value/exist in my JSON, how can I echo 0 in it's place?

            foreach ($content as $row) {
                $impressions = $row['impressions'];
                $clicks = $row['clicks'];
                $visits = $row['nb_visits'];
                $bounces = $row['bounce_count'];
                $bounce_percent = $row['bounce_rate'];
                $conversions = $row['nb_visits_converted'];

                print("<tr>");
                print("<td class='month subscriber subscriber-fixed-alone fixed-cell'>$results</td>");
                print("<td class='stat number text-center'>$impressions</td>");
                print("<td class='stat number text-center'>$clicks</td>");
                print("<td class='stat number text-center'>$visits</td>");
                print("<td class='stat number text-center'>$bounces ($bounce_percent)</td>");
                print("<td class='stat number text-center'>$conversions</td>");
                print("</tr>");
            }

If you need to see the full PHP then let me know. It is mostly just calling fetching the HTTP API url.

Aucun commentaire:

Enregistrer un commentaire