This might be crazy, but I was thinking there might be a shorthand way to do this without using a loop on one php line... over-optimizing fun!
$stars = 4; // four out of ten stars
print stars with a loop
for($i=0;$i<$stars;$i++){
echo "<i class='fi-star'></i>";
}
print without loop
<?=implode("",array_fill(0,$stars,"<i class='fi-star'></i>"))?>
is there a simpler way?
str_repeat"is there a simpler way?"- Simpler than... a loop? If you want to repeat an action until a condition is met, that's exactly what a loop is for. You're likely saving nothing in optimization but costing time in obtuse code. Even if you somehow manage to save a millisecond is processing time, it's going to require a lot of application volume to make up for all the development time spent creating and supporting "clever code".