Back to DFS's PHP Page


OAC Problem Set I

Strings Problem

For this problem (or rather pair of problems), you are to utilize a dir_list.dat file as created in Reading an Unknown Amount of Data from a Disk File, but for the ~/YOURID/public_html directory.

The data in the directory listing can be of considerable utility. Your job is to write a web page utilizing a form into which the user will type a string. A second script, using PHP, will scan through the file and produce a web page which repeats the string searched for and then lists all lines from the file which contain a match.

This pair of scripts should produce the same sort of output on a web page that the following would on the Command Line

ls -l | grep XXX
where XXX represents a substring to be found in the listing.

The resulting web page should specify the number of lines where the substring was found.

If the substring is not found, a user-friendly message should be given.

Extra Credit

You are to find a way to allow the user to specify a date in the form. Any lines which have files with that date or later are to be listed.

For this problem, you will need to learn how to use the string explode function and arrays.


© DFStermole 2002
Created 22 Sept 02