User Tools

Site Tools


eg-259:homework:17

Introduction to PHP

Adapted from: Robert W. Sebasta, Programming the World-Wide Web, 3rd Edition, Addison Wesley, 2006. Supporting: An Introduction to PHP (Part 1) and (Part 2).

1. Homework Exercises

Write, test, and debug (if necessary) PHP scripts for the following specifications. For the exercises which ask you write function, write the functions and the code to test them.

  1. Parameter: An array of strings. Return value: A list of the unique strings in the parameter array.
  2. Parameter: an array of numbers. Return value: The average and median of the parameter array.
  3. Parameter: A string of numbers separated by spaces. Return value: The first four-digit number in the string.
  4. Modify the sample script word_table.php discussed in the lecture to place the output table in an HTML table.

2. Additional Howework Exercises

These additional exercises, all from Chapter 12 of Sebasta, can be tried if you need more challenges.

  1. Parameter: An array of strings. Return value: A list of the three strings that occur most frequently in the parameter array.
  2. Parameter: An array of numbers (pass-by-value) and two arrays (pass-by-reference). Return value: None. Result: The first pass-by-reference parameter must have the values of the given array that are greater than zero the second must have the values that are less than
  3. Parameter: A string containing words that are delimited on the left with spaces and on the right with commas, periods, or question marks. Return value: The three most common words in the string that have more than three letters.

More Homework Exercises

eg-259/homework/17.txt · Last modified: 2013/03/08 18:02 by eechris