Loop in PHP Using For (Descending)

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. <?php
  2. /* Loop in PHP Using For (Descending)
  3. For those times you need to do a loop in PHP, but have the outcome be in descending order (ie, start at 10 and end at 1). */
  5. $totalcode="10";
  6. for($i=$totalcode; $i>0; $i--){
  8. echo"$i";
  9. }
  10. ?>

URL: http://www.bigbold.com/snippets/posts/show/2219

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.