Programming-Idioms

History of Idiom 2 > diff from v98 to v99

Edit summary for version 99 :
New PHP implementation by user [Isotopp]

Version 98

2019-09-28, 21:49:56

Version 99

2019-09-29, 11:45:04

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
foreach(range(1, 10) as $i)
  echo 'Hello'. PHP_EOL;
Comments bubble
Using range() instead of counting, because we can.
Doc URL
https://www.php.net/manual/en/function.range.php
Demo URL
https://3v4l.org/CMvoZ