Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = <<<END
- 10 15
- Time
- flies
- like
- an
- arrow
- but
- fruit
- flies
- like
- a
- banana
- Groucho
- Marx
- END;
- //number of word, width
- $input = explode("\n", $input);
- $first_line = explode(" ", array_shift($input));
- $width = $first_line[1];
- //ignore the word count
- foreach($input as $key => $value){
- $echo_key = $key+1;
- echo str_pad($value, $width-strlen($echo_key), '.', STR_PAD_RIGHT).$echo_key."\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment