MMDT1146 PHP Programming
Week 3


Week 3

General Notes:

  • Set up a shortcut in your browser for the PHP documentation.

Lab 3

This lab is to test your knowledge of being able to use arrays, strings, sorting, and loops.

Create a subfolder on your webserver named "strings " or something similar(This may already be done for you from doing the in class exercises.)

Under the subfolder "strings" that you just created, you will need to create two files.  The names are of your choosing.  In my example, I called them "form.php" and "results.php".

The lab must contain several items.  Your resulting output should like similar to this.

Title your pages.
Put captions on the top of your pages.
Add a background.

On the first page:

Draw a form with checkboxes, a textbox, a hidden field, and a submit button like my example.
Name your form, checkboxes, textbox, and hidden field.
Create a small PHP script on this page to pass a secret message that contains your name (about one sentence) of your choosing to the results page via the hidden field.

On the results page :

Echo your secret message that was passed in the hidden field.

  1. Write a PHP script to alphabetize all the words in the submitted paragraph.
    Be sure to strip out punctuation and to convert the string to all lower case characters.
    Convert the string to an array of words.
    Sort the array in alphabetical order.
    Echo the array to the screen.

  2. Write a PHP script to display in frequency all the words in the submitted paragraph.
    Be sure to strip out punctuation and to convert the string to all lower case characters.
    Convert the string to an array of words.
    Count the number of times the words are used.  Hint: array_count_values($arrayname)
    Sort the array in frequency order.
    Print the array to the screen.  Hint: print_r($arrayname)

  3. Write a PHP script to display the frequency of all the alpha letters used in the submitted paragraph.
    Convert the string to all lower case characters.
    Create an array of all found characters in the string.  Hint: You will need a "for" loop.
    Echo the array in alphabetical order to the screen.   Hint: You will need a "for" loop.

Test your scripts using large amounts of text.  Cut and paste news articles for testing.

Assignment is due 1 week from when it was assigned.  50% penalty if late.

MMDT 1146 Lab 3
Grading Criteria
Date:

Possible
Points
25
Your
Points
25
Pages are titled, captioned, and have a background. 2 2
The first page is created checkboxes, textbox, and a hidden field. 4 4
The first page W3C validates. (provide screenshot in dropbox) 1 1
The hidden field passes the student name to the results page and is displayed on the results page. 2 2
Script #1 on the results page works as described above. 5 5
Script #2 on the results page works as described above. 5 5
Script #3 on the results page works as described above. 5 5
The results page W3C validates. (provide screenshot in dropbox) 1 1