PHP return a certain amount of code based on a value
<p>I am trying to create a visual representation of a user rating from 1 to 5 (including .5 values) in the form of stars and half-stars.  I have already created the array of user ratings from the MySQL database, I have averaged those values to create an average user rating in the form of a number.  What I would like to do is take this value..</p>

<pre><code>$averageuserrating
</code></pre>

<p>And if that value is "1", then return this code once </p>

<pre><code> echo '&lt;img src="images/star.png" class="ratingstar" /&gt;';
</code></pre>

<p>If $averageuserrating is 1.5, then this code will be returned</p>

<pre><code>&lt;img src="images/star.png" class="ratingstar" /&gt;&lt;img src="images/halfstar.png" class="ratingstar" /&gt;
</code></pre>

<p>And so on... Is there a way to do this without 10 nested if statements?</p>
