Built-in function calculates the time of sunset and sunrise with latitude, longitude, zenith, and GMT offset. Added in PHP 5. (Credit: http://www.php.net/manual/en/function.date-sunset.php under ODL1.0)
Randomly select an image from an array and display it with an <img> tag. Useful as an advertisement rotator. (Credit: apress.com)
This is a script that demonstrates simple form handling in PHP. The script prints a form to the browser that submits to itself. The script checks to see that the "posted" variable was set by the form (meaning the form has been submitted), processes the form information, and prints out a message indicating that the submission was successful.
I wasn't really sure what to call this, but I've been doing it forever. So I thought I'd create a little example. This is very basic, it can be expanded too. Below, the p variable will be referring to the current page.
This is a striped down version of the code used to generate the tabs in the search results pages. This function returns an array of the page numbers to be displayed. The array keys are ordered as they should be displayed (you could simply cycle through the array with foreach to display the page numbers). It will return a maximum of 15 page numbers, and if there are more than 15 page numbers, it will show the first and/or last 2 page numbers of the results. The array values represent the page number, and array values that are '0' represent where extra page numbers have been truncated.
Using the foreach construct to cycle through an array.
An example of using functions embedded within functions. (Courtesy apress.com)