Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = fgets(STDIN);
- $input = str_replace(",", "", $input);
- $input = str_replace(".", "", $input);
- $input = str_replace("-", " ", $input);
- $input = str_replace(":", " ", $input);
- $suffix = strtok($input, "|");
- $text = strtok("|");
- $result = strtok($text, " ");
- $i = 0;
- $textArray[0] = false;
- while($result !== false)
- {
- if(preg_match("/$suffix\z/", $result))
- {
- $textArray[$i] = $result;
- $i++;
- }
- $result = strtok(" ");
- }
- if($textArray[0] != false)
- {
- sort($textArray);
- echo "<ul>";
- foreach($textArray as $value)
- {
- echo "<li>" . $value . "</li>";
- }
- echo "</ul>";
- }
- else
- {
- echo "<ul></ul>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement