php - i want to apply condition on foreach -
i want apply condition on json array using php here display data has type discursive
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
Post a Comment