I'm trying to iterate a JSON Array and display the elements in DOM? My JSON Schema
[
{
"pic": "<?php echo base_url();?>assets/images/testi_pic1.jpg",
"desc": "My experience with Vestedu has been great. I was able to save money on my student loan, they have competitive rates, excellent customer service and easy application process",
"name": "Ram Chandra",
"degree": "MBA",
"desig": "designation"
},
{
"pic": "<?php echo base_url();?>assets/images/testi_pic2.jpg",
"desc": "My experience with Vestedu has been great. I was able to save money on my student loan, they have competitive rates, excellent customer service and easy application process",
"name": "Ram Chandra",
"degree": "MBA",
"desig": null
}
]
My PHP Code
<?php
$str = file_get_contents(base_url(). 'assets/data.json');
$json = json_decode($str, true); // decode the JSON into an associative array
$count = count($json);
for ($i=0; $i < $count; $i++) {
echo '<pre>' . print_r($json[$i], true) . '</pre>';
}
?>
Now I'm able to extract Objects from the Array, How do I iterate through this HTML?
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="testimonialbox">
<img src="<?php echo base_url();?>assets/images/testi_pic1.jpg" alt="testimonial" />
<p>"My experience with Vestedu has been great. I was able to save money on my student loan, they have competitive rates, excellent customer service and easy application process"</p>
<div class="testimonial-author-box">
<i class="fa fa-quote-right" aria-hidden="true"></i>
<h3>Ram Chandra</h3>
<span>MBA</span>
</div>
</div>
</div>
{$json[$i]["name"]}
";` basically? (The can of worms with ` – mario Jan 08 '19 at 23:29