Without using a for/while loop or any kind of string repeat function and a single PHP file, print out the text “All work and no play makes jack a dull boy” to the screen 200 times in a list – Grade C: 15 lines of code – Grade B: 10 lines of code – Grade A: 7 lines of code – Grade A*: 4 lines of code (VERY difficult)
– n.b. a “line” counts as a statement. Each closing brace must go on its own line, function calls on their own line and function declarations on their own line. PHP tags
You can use php's array_fill()
method to fill an array 200 times with your data. http://php.net/manual/en/function.array-fill.php
After that you can use implode()
to print that information out to the screen without using a loop. Show array without index key
Of course, both of these methods will utilize a loop internally, but your code will be free of these.
This should work:
$a = array_fill(0, 200, 'banana');
echo implode($a, '<br />');