title: Recursive PHP Star-Rating function not working
body: <p>I am trying to write a Star-rating function in PHP to <strong>return</strong> the result (not just echo it).</p>
  
  <p>My newer version is:</p>
  
  <pre class="lang-php prettyprint-override"><code>function getRating($rating, $ret = '') {
      if ($rating == 0) { return $ret; }
      if ($rating &lt; 1) {
          $ret .= '&lt;span class="fa fa-star-half-empty"&gt;&lt;/span&gt;';
          $rating-= 0.5;
      } else {
          $ret .= '&lt;span class="fa fa-star"&gt;&lt;/span&gt;';
          $rating-= 1;
      }
      getRating($rating, $ret);
  }
  $var = getRating(5.0);
  </code></pre>
  
  <p>This returns null. The older version just echo it but I want it to hold the rating in a variable:</p>
  
  <pre class="lang-php prettyprint-override"><code>function getRating($rating,) {
      if ($rating == 0) { return; }
      if ($rating &lt; 1) {
          echo '&lt;span class="fa fa-star-half-empty"&gt;&lt;/span&gt;';
          $rating-= 0.5;
      } else {
          echo '&lt;span class="fa fa-star"&gt;&lt;/span&gt;';
          $rating-= 1;
      }
      getRating($rating);
  }
  getRating(5.0);
  </code></pre>
  
  <p>This one shows the <code>&lt;span&gt;</code> with the stars. What I am doing wrong in the first function? Thanks in advance.</p>