php - i want to apply condition on foreach -


i want apply condition on json array using php here display data has type discursive

my json file

here code trying not showing data want

 <?php   $obj2 = json_decode($blog_data);   foreach(array_reverse($obj2->blogs) $blog)   {     if($obj2>b_type == 'discursive')   {   ?>       <h3> <?php echo $blog->name; ?></h3>       <span> <?php echo $blog->date; ?> </span>         <p><?php echo $blog->b_text; ?></p>    <?php   }   else{     echo "no discursive event";   }   }  ?> 

try this:

    <?php     $obj2 = json_decode($blog_data);     foreach(array_reverse($obj2->blogs) $blog)     {         if($blog->b_type == 'discursive')         {        ?>             <h3> <?php echo $blog->name; ?></h3>             <span> <?php echo $blog->date; ?> </span>             <p><?php echo $blog->b_text; ?></p>         <?php        }         else{             echo "no discursive event";         }     } ?> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -