Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Output a list of numbers multiple times depending on their value (e.g. output 9 nine times, or 18 eighteen times). Works well if it doesn't matter if you listall the numbers preceding the last number
- */
- $array = array(1,2,3,4,5,6,7,8,9,12,18);
- foreach ($array as $num) {
- $string = '';
- $count = 1 * $num;
- for ($i=0;$i < $count; $i++) {
- $string .= (string)$num;
- }
- echo $string.PHP_EOL;
- }
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement