1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4. <head>
5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6. <title>I Have This Sorted Out</title>
7. </head>
8. <body>
9. <?php // Script 7.7 - handle_list.php
10. /* This script receives a string in $_POST['words']. It then turns it into an array,
11. sorts the array alphabetically, and reprints it. */
12.
13. // Address error management, if you want.
14.
15. // Turn the incoming string into an array:
16. $words_array = explode(' ' , $_POST['words']);
17.
18. // Sort the array:
19. sort($words_array);
20.
21. // Turn the array back into a string:
22. $string_words = implode('<br />', $words_array);
23.
24. // Print the results:
25. print "<p>An alphabetized version of your list is: <br />$string_words</p>";
26.
27. ?>
28. </body>
29. </html>