The glob() Function In PHP

25th March 2008

The glob() function in PHP uses simple pattern matching to find files and directories in a directory and return those file names as an array. It simplifies all of the PHP directory functions, so instead of opening the directory and then reading every file name one by one, you can just use glob() and so it in one function call. Additionally, glob() works very closely with the file system and so it very quick.

Here is a simple example.

Common Regular Expressions

Here are some of the regular expressions that I frequently use.

Find a blank line

^$

Spaces

[ \t]+

You can use this to break a text string apart into words.

Date

\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}

This will match anything in the format mm/dd/yyyy, or even dd/mm/yyyy.

philipnorton42 Mon, 03/24/2008 - 09:32

MooTools Home Page

23rd March 2008

If you are looking for information about the MooTools JavaScript framework then your first stop should be the MooTools home page. The site not only allows you to download MooTools, but it is also a great resource for learning how to use MooTools.

RegExLib.com: The Regular Expression Library

Writing regular expressions can sometimes be a real pain, especially if you are not used to them. Rather than trying for yourself to make a regular expression you might want to think about looking for regular expressions that other people have made. Rather than reinventing the wheel to prove you can do something,using free third party regular expressions can save you a lot of time.

philipnorton42 Sat, 03/22/2008 - 22:51

reWork: A Regular Expression Workbench

21st March 2008

Regular expressions are a very useful tool for any programmer wanting to validate input, format strings, change words, reformat data or even split apart a string into an array. However, when you are starting out, writing them it can be hard going, they are not very easy to learn and the only way to really understand them is to practice, practice, practice.

Finding The Latest Timestamp Value From A Set Of Values In MySQL

20th March 2008

Storing sets of data with a timestamp is common practice, especially if you want to keep a history of the values that have been stored previously. Lets say you wanted to store a piece of information about two variables, each of which can have a history. Here is an example dataset.

Save Browser Output To A File With PHP Output Buffering Functions

The PHP output buffering functions provide a handy way of intercepting the contents of the buffer before it is sent to the browser. The output is whatever is sent to the browser whenever you print something off. PHP allows you to capture this output in a buffer before it is sent to the browser.

philipnorton42 Wed, 03/19/2008 - 09:47

A Garbage Collection Mechanism In PHP

18th March 2008

Garbage collection is a term for a maintenance function in a class or script that you don't want to run every time the script is run. The main function of the script is to clean up anything that the script has used previously, but is now not important in the general running of the system and can be removed with no ill effects. However, it is important that the garbage collection is not run every time the script is run as it may have a detrimental effect on the speed of the system.

www.php.net

17th March 2008

By far the best resource for finding information about PHP and all of the functions available is from the PHP website. Not only can you view the PHP documentation, but you can also download PHP and many of the extensions like the Smarty template system.

PHP5 Filter Functions Part 2

15th March 2008

Following on from the previous post about the PHP filter functions there are two more filter functions that require some extra explanation. These functions are filter_var_array() and filter_input_array().

They work in much the same way as filter_var() and filter_input() but they accept an array as the input. This enables you to sanitize or validate many different variables at the same time.