Let's say I run my counter at 400. How would I execute a foreach loop that would run back to 0?
pseudo code
$i = 400; foreach(**SOMETHING**)){ //do stuff $i--; }
for($i = 400; $i > 0; $i--) { // do stuff }
other ways to do this:
$i = 400; while($i > 0) { // do stuff $i--; }
or
$a = range(400, 1); foreach($a as $i) { // do stuff }
If you really want to iterate back over an existing array, you can use array_reverse () :
foreach(array_reverse($myArray) as $myArrayElement){ // do stuff with $myArrayElement }
for
for($i = 400; $i > 0; $i--) { //stuff }
foreach . , for while.
foreach
while
Source: https://habr.com/ru/post/1728975/More articles:CakePHP & Subselects - subqueryWindows 7 taskbar tasks without window in .Net - windows-7Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΠΈ ΠΏΠΎ ΠΈΠ½ΡΠ΅Π³ΡΠ°ΡΠΈΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Rails Ρ Π²Π½Π΅ΡΠ½ΠΈΠΌΠΈ API-ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ°ΠΌΠΈ? - apiweb audio player without flash - streamSet the double-click event without disabling the default mouse behavior of the mouse / mousedown - flexphp to generate drop-down lists MM / DD / YYY and HH / MM with the selected current date - phpIdentification of a C # or C ++ function is launched in a string counting program - c ++Preliminary receipt of files in the cache of the Windows page - performanceΠΡΠΈΡΠ°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠΊΠ°Π·Π°ΡΠ΅Π»Π΅ΠΉ - cUsing + operator without memory leak? - c ++All Articles