title: Condensing PHP code into functions
body: <p>I have a repeating code in php that I would imagine I can somehow condense into a function and simply call the function multiple times.  I tried doing this and nothing appears to happen.  This is on repetition of the old code:</p>
  
  <pre><code>if ($health_1 &gt; $health_2) {
      $health_left = '#7fba00';
      $health_right = '#e81123';
  } else if ($health_perlvl_1 == $health_perlvl_2) {
      $health_left = '#0451ff';
      $health_right = '#0451ff';
  } else {
      $health_left = '#e81123';
      $health_right = '#7fba00';
  }
  </code></pre>
  
  <p>and this repeats about 12 times with other stats.  I decided to try to condense it to this:</p>
  
  <pre><code>function stat_color($stat_1,$stat_2,$color_left,$color_right) {
      if ($stat_1 &gt; $stat_2) {
          $color_left = '#7fba00';
          $color_right = '#e81123';
      } else if ($stat_1 == $stat_2) {
          $color_left = '#0451ff';
          $color_right = '#0451ff';
      } else {
          $color_left = '#e81123';
          $color_right = '#7fba00';
      }   
  
  }
  stat_color($health_1,$health_2,$health_left,$health_right);
  </code></pre>
  
  <p>But the colors are not there later when they are needed.  Is there any way to actually get this to work?</p>