PHP Tutorials
Quick Tip: Object Indexing vs. Array Collection
Let's say that we have one large text document and we have a a bunch of keywords that we want to parse the document for. We don't care how many times times the keyword appears — we just care that it's been used. When we find a keyword, we need to record that keyword been found so that we may check at a later time.
Change Category Slug within WordPress
When I first started this blog, I set the category "slug" to "sugar." Why sugar? Because a lot of a good thing is candy; thus, a bunch of MooTools tutorials is as sweet as sugar. While I get a giggle out of calling my categories sugar, Google doesn't find it nearly as funny, nor does Yahoo or Bing. In an effort to increase my SEO, I wanted to change my category slug to "tutorials." That's where the awesome Redirection plugin and a simple regular expression comes into place.
Build HTML Tables From MySQL Tables with PHP
I was recently completing a project which required that I build a series of HTML tables which would represent all of the tables within a MySQL database. I didn't have anything created but after a few minutes I had exactly what I needed. Hopefully this helps you out!
Create a “Recent Posts” Module Outside of WordPress
The websites I create are never powered by WordPress. Sure I may add a blog to the website but I've never created a client website that was run by the powerful blogging software. In an effort to tie the website and blog together, I'll usually do some quick PHP/MySQL programming to pull in recent blog post titles and links to the individual posts. Here's the PHP and MySQL that accomplishes that task.
Create Bit.ly Short URLs Using PHP: API Version 3
Bit.ly is a great URL shortening service. I love their reliability, shortness of the URL, and the information they provide about a given URL. Recently Bit.ly updated their API to version 3 so I thought I'd update my original Bit.ly post. Here's how you can create short URLs and expand short URLs using Bit.ly.
iPad Detection Using JavaScript or PHP
The hottest device out there right now seems to be the iPad. iPad this, iPad that, iPod your mom. I'm underwhelmed with the device but that doesn't mean I shouldn't try to account for such devices on the websites I create. In Apple's developer tip sheet they provide the iPad's user agent string:
Automatically Generate a Photo Gallery from a Directory of Images: Updated
Two years ago Chris Coyier wrote an outstanding tutorial detailing how you can generate a photo gallery based on the images within two directories: a thumbnails directory and an originals directory. I've decided to take his tutorial a step further by showing you how to generate thumbnails for the gallery using PHP. I've also implemented a MooTools lightbox: Smoothbox. The following code will show you how to create a beautiful photo gallery by simply dumping your photos in a directory.
Using MooTools ScrollSpy to Load More Items via JSON/AJAX
Last July I wrote an epic dominant unbelievable fantastic outstanding awesome NetTuts post called Create a Twitter-Like "Load More" Widget Using CSS, HTML, JSON, and jQuery or MooTools where I used a MooTools/AJAX/JSON system for loading additional items when the user clicks a "Load More" link. The functionality is sweet but I see room for improvement. If a user scrolls down toward the end of the container, why not load more items for them automatically? Armed with the premier MooTools scrolling plugin, ScrollSpy, we can do so.
ID Your Body Using PHP
It seems like every part of a website needs to be dynamic. Dynamic, database-driven pages, dynamic JavaScript, dynamic CSS, etc. All this dynamism can make it difficult to style or script a page easily. One way I've learned to combat the rigidness of using CMS' is to give the BODY element a unique ID based on the URL. Doing so allows me to add special styling to any page.
Replace Content in PRE Tags with HTML Entities
If you have a website that relies heavily on PRE tags, you know the important of converting PRE tag content to their HTML entities. Doing so prevents worlds of possible rendering issues. The following PHP snippet HTML-Entitizes (?) any code within PRE tags: