RU beehive logo ITEC dept promo banner
ITEC 325
2011fall
ibarland

homelectsexamshws
breeze (snow day)

lect04a

Exercise: Let's write a function which takes in the name of a directory, and returns a string mentioning each file in the directory: something like:

"One file is someFile.txt.<br />Another file is someFile2.txt.<br />Another file is Zzzz.php.<br />"
Hint1: scandir.

Exercise: Write a function that takes in an array of key/values pairs, and returning a string that happens to be html for a pull-down menu of those values.

test( HTMLPulldown( array( "Jan" => "January", "Dec" => "December" ) ),
      "<select
  <option value='Jan'>January</option>
  <option value='Dec'>December</option>
</select>" );


test( HTMLPulldown( array( "January", "February", "December" ) ),
      "<select
  <option value='0'>January</option>
  <option value='1'>February</option>
  <option value='2'>December</option>
</select>" );
  
This is pretty cool. However, looking closely at the generated HTML, there is one thing missing: we want our select node to include a name attribute. What do we need to tweak?

Optional: extend the above by including an optional parameter: a top-option like “please select:”.

Left as an exercise: Similar to above, make a function that takes in an array, and returns (the html for) a bunch of checkboxes, inside table.



1Usually, a google search like “php list files” gives good matches; in this particular case we get sidetracked by related functions that deal with file-handles and are iterators.      

homelectsexamshws
breeze (snow day)


©2011, Ian Barland, Radford University
Last modified 2011.Sep.21 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme