Stump of a Muffin

Category: PHP Toppings

Some of the PHP ‘toppings’ I’ve collected and thought worth sharing. Actually, I’m most likely to return to these pages as a resource for myself.

.htaccess – Denied

Every wanted to keep everyone out of a directory?  Make your .htaccess file this way: deny from all Now that entire directory is ‘blocked’ from prying eyes. How about not allowing any site visitor from parsing a resource? It goes a little like this: <Files *.phpi> deny from all </Files> Now any file with the…

Alphabetize an Array

Reading a directory and putting the files found into an array shouldn’t be such a big deal, right?  How about alphabetizing that array? function read_a_directory( $DIR ) { if ( is_dir( $DIR ) ) { if ( $dh = opendir( $DIR ) ) { while ( ( $file = readdir( $dh ) ) !== false…

Alternating

There are dozens of ways to alternate.  The most common and visible is the background colour of your tabular data.  I use PHP to generate my HTML and the following are my two favourites: foreach( (array)$results AS $K => $V ) {$alt = ( $alt == ‘odd’ ) ? ‘even’ : ‘odd’ ;} This works…