ITT #6: PHP Arrays as Return Values

In this installment of Instant Tip Tuesday, we're going to talk about arrays in PHP. According to the PHP manual, an array is "an ordered map that associates values to keys." The benefit of using arrays is that we can pack a ton of data into one variable, which means we can pass that data back through a function.

What's So Cool About Passing Arrays?

I use arrays as return values to keep my processing of data separate from the formatting of said data. This is done in an effort to make code maintenance easier in the future. For example, look at the following code:

<html> <body> <?php require_once '_db/mysql.php'; // Connect to the database $data = getDataFromDB("blog", 5); // returns latest 5 blog entries ... read more

FlickrScrollr Explained: PHP

NOTE: Ok, so I totally rushed the FlickrScrollr out the door on Tuesday in order to keep the Instant Tip Tuesday series alive (because, let's face it, if I'd only made it three weeks before I missed a Tuesday—well, I wouldn't be much of a blogger at all, would I?). However, in doing so, I didn't really explain how the plugin works or any of the advanced configurations of it. In an effort to rectify that, I'm going to break the code down in this post.

The Goal of This Post

First, I'd like to readdress what FlickrScrollr is and how it works, then I'd like to pick apart how the plugin was built. Because this plugin uses both a PHP class and a jQuery plugin, this writeup is going to... read more

ITT #4: Plugin Giveaway - FlickrScrollr

UPDATE: I've posted a new entry explaining FlickrScrollr. Please refer to that article for better implementation instructions, as well as a breakdown of how the code works.

In an effort to squeak in this week's Instant Tip Tuesday before midnight, I'm going to give away a PHP+jQuery plugin to create an animated Flickr module on your site. I call it FlickrScrollr.

View the Demo | Download the Files

What Is FlickrScrollr?

FlickrScrollr is a combination of PHP5, jQuery, and CSS. It utilizes PHP's SimpleXML extension to parse a user's Flickr RSS feed, then uses jQuery to add animation to the generated display of thumbnails, finally topping off the fun with Leandro Vieira Pinho's jQuery Lightbox plugin.

How Do I Use FlickrScrollr?

To implement FlickrScrollr... read more

ITT #2: Automate Your Copyright Years

If you've built blogs for clients before, or created a site based on a content management system, then you know keeping copyright information up-to-date can be a pain.

It used to be that every year, I'd have to pull up every single client's site and edit the year, which would eat up a full day of my time. It was a terrible way to start the new year, and after a couple years of tedium, I decided to deal with it once and for all.

View the Demo | Download Source

Automatically Update the Year

My first instinct was to simply use PHP's handy date() and time() functions to automatically find the year. To get the current year, you can use this snippet of code:

<?php echo... read more