dimanche 27 octobre 2019

How to only get "true" elements from json

I only want to get the true elements, i can do that, but it also outputs a lot of blank spaces

This is what a news line look like

  "news": [
    {
      "title": "Titulo",
      "body": "Aqui fica o conteudo",
      "image": "Imagem",
      "live": true
    },

And i'm doing this to get the news

<?php foreach ( $json['news'] as $noticias ) : ?>

 <?php 

if($noticias['live'] == "true"):

echo $noticias['title'];

?>

<?php endforeach; ?>

This outputs only the "true", but also outputs a lot of spaces like this

Titulo
Titulo
Titulo

















Aucun commentaire:

Enregistrer un commentaire