Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $animals = file('https://gist.githubusercontent.com/atduskgreg/3cf8ef48cb0d29cf151bedad81553a54/raw/82f142562cf50b0f6fb8010f890b2f934093553e/animals.txt', FILE_SKIP_EMPTY_LINES);
- sort($animals);
- $last = '';
- foreach ($animals as $animal) {
- $current = substr($animal, 0 ,1);
- if($current !== $last) {
- echo $current, ' ---<br>', PHP_EOL;
- $last = $current;
- }
- echo $animal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement