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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -