Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Loop In PHP Using For (Descending)

DZone's Guide to

Loop In PHP Using For (Descending)

·
Free Resource
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).


$totalcode="10";
for($i=$totalcode; $i>0; $i--){

 echo"$i";
}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}