Functions and Strings  
 
 

Week 2

Readings:
The PHP reading for this week is chapters 3 and 4 in Progamming PHP.

Key Concepts:
-using function in PHP
-creating functions in PHP
-displaying strings
-substrings
-comparing strings
-regular expressions in PHP

Exercises:
This week you will make some functions. Your first function should take in a date string in mm/dd/yyyy form and print out a sentence something like "it is the ddth day of month number mm and the year is yyyy" using printf(). Use regular expressions to break up the date and perhaps some if statements (or a switch statement) to correctly choose between st,nd,rd, and th as endings for the numbers in the sentence. The second function should take in a sentence string and return the first word in the sentence without using regular expressions. Also include some code to test your functions and make sure it works correctly. Include the header and footer files from week 1 and add a link to this week's assignment to the footer file. As always feel free to explore anything else that looked interesting!


Files to Be Downloaded