php - how do I edit the output of fgetcsv -
i'm using ekomi , want pull in reviews website. i've managed working there's slight problem. every single review getting added, , in reverse order.
you'll see code below using fgetcsv
.
is possible limit 12 latest reviews? , order them newest oldest?
here's code i've put together.
<div class="row"> <div class="row__colspaced"> <?php $row = 1; if (($handle = fopen("http://api.ekomi.de/get_feedback.php?interface_id=66630&interface_pw=f2d097e83db1880e85e2f77aa&range=3m&type=csv", "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { echo "<div class='colspan12-4 colspan6-3 as-grid with-gutters'><div class='content-module--review-list__item item' data-mh='review-item'>"; $num = count($data); $row++; ($c=0; $c < $num; $c++) { if($c == 0){ echo gmdate('y-m-d h:i:s',$data[$c]); } else if($c == 2){ if($data[$c] == 1){ echo '<div class="fa-star-rating"> <i class="fa fa-star"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> </div>'; } if($data[$c] == 2){ echo '<div class="fa-star-rating"> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> </div>'; } if($data[$c] == 3){ echo '<div class="fa-star-rating"> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star-o"></i> <i class="fa fa-star-o"></i> </div>'; } if($data[$c] == 4){ echo '<div class="fa-star-rating"> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star-o"></i> </div>'; } if($data[$c] == 5){ echo '<div class="fa-star-rating"> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> </div>'; } } else { echo '<div class="inner-item item'.$c.'">' . $data[$c] . "</div>"; } } echo "</div></div>"; } fclose($handle); } ?> </div> </div>
Comments
Post a Comment