title: PHP get result of function within echo
body: <p>I want to echo out the result of a function within the initial echo.</p>
  
  <pre><code>echo "&lt;div class='booking-item-rating'&gt;" . stars($hotelSummary[$x]['hotelRating']) . "&lt;/div&gt;";
  </code></pre>
  
  <p>The function:</p>
  
  <pre><code>function stars($stars){
  for($i=1;$i&lt;=$stars;$i++) {
      echo "&lt;i class='fa fa-star'&gt;&lt;/i&gt;";
  }
  if (strpos($stars,'.')) {
      echo "&lt;i class='fa fa-star-half-empty'&gt;&lt;/i&gt;";
      $i++;
  }
  while ($i&lt;=5) {
      echo "&lt;i class='fa fa-star-o'&gt;&lt;/i&gt;";
      $i++;
  }
  }
  </code></pre>
  
  <p>The problem is that the result of the function is printed outside the initial echo field, outside of the div element. How do I get the result of the function to print out within the first echo ?</p>