title: how to make fibonacci stop by last input number in php
body: <p>I have this input and output:</p>
  <p>Input : 3 <br>
  Output : 1 1 2 3 <br><br>
  Input : 5 <br>
  Output : 1 1 2 3 5 <br><br>
  Input : 12 <br>
  Output : 1 1 2 3 5 8 <br><br>
  Input : 25 <br>
  Output : 1 1 2 3 5 8 13 21  <br></p>
  <p>I have tried summing up using this code:</p>
  <pre><code>&lt;?php
    function fibonaci($total)
          {
              $previousNum=1;
              $numbersNow=1;
  
              $valueOutput = &quot;$previousNum $numbersNow&quot;;
  
              for ($i=1; $i&lt;$total; $i++)
              {
                $output = $numbersNow + $previousNum;
                $valueOutput = $valueOutput . &quot; $output&quot;;
  
                $previousNum = $numbersNow;
                $numbersNow = $output;
              }
              return $valueOutput;
          }
  
          echo fibonaci(3);
          echo &quot;&lt;br&gt;&quot;;
  
          echo fibonaci(5);
          echo &quot;&lt;br&gt;&quot;;
  
          echo fibonaci(12);
          echo &quot;&lt;br&gt;&quot;;
  
          echo fibonaci(25);
          echo &quot;&lt;br&gt;&quot;;
  ?&gt;
  </code></pre>
  <p>Which outputs: <br>
  1 1 2 3 <br>
  1 1 2 3 5 8 <br>
  1 1 2 3 5 8 13 21 34 55 89 144 233 <br>
  1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393</p>