Browsing articles in "Tricks"
Jun
24
2014

Download Files with PHP (From a List)

Ever have one of those days where you get a new codebase on your desk, but realize that you’re missing ALL THE IMAGES?  (face slap). I’ve had plenty of those, and here’s how to stop slapping yourself and just use PHP to download files from a list in a text file! The Directory Structure Easy enough, but just to be safe, the following is the directory structure used for this: process.php attachment.txt files/ Process.php The […]

Jun
20
2014

My favorite tools for Web Development

The question that I get asked more than any other is, “What tools do you use to code?”, so I figured I’d spread some software/knowledgebomblove and lay out my workflows! I’ll also break it down by the actual order of my workflow (since that’s a bit easier for me to write/remember anyway): Textmate I code by hand, and since I code by hand, Dreamweaver isn’t even a thing that exists on my computer.  I use […]

Jun
8
2013

Awesome Email open tracking with PHP and MySQL

Sometime last year, I wrote about super awesome email open tracking using PHP and MySQL, and I’ve since ALSO updated that one to be EVEN MORE SUPER AWESOME! Tracking email open rates is both very valuable, and very useful, particularly if you run a service where statistics are important, or in scenarios where more detailed information on users (namely their participation with site content outside the website is crucial). That being said, a couple things […]

Oct
13
2011

Using PHP to merge and minify CSS and Javascript

And yet another ‘bangin’ update!  Don’t use this (I’m going to leave it here for reference), use the magicmin javascript and css minification/caching class instead for performance, better javascript minification, caching, gzip, base64_encoded images, and more! One MAJOR factor in the usability of your website is site load time.  This is affected by a number of factors: the number of images, database queries, and the number of server requests to fetch your stylesheets and javascript […]

Sep
24
2011

Synchronous Input Population Using JavaScript

Synchronization for html input forms

Working with code can often be tedious, and frequently requires programmers to continually reference functions or other sets of code that exists on different pages.  For example: As a relative newbie to wordpress, when creating or modifying files I spend ~70% of my development time looking through files for correct/applicable function usage.  If I wish to display an option to edit a post in a template, I must use “edit_post_link(‘edit’, ‘<p>’, ‘</p>’);”, however, the chance […]

Aug
25
2011

Using PHP to Replace Special Characters with their Equivalents

PHP Character Replacement

After having just completed an extensive text file parsing script, I discovered something very very very annoying.  A small army of Microsoft Word inspired characters had invaded the imported plain text files (courtesy a number of citation management softwares and websites), causing text to have all sorts of ‘fun’ symbols sprucing things up. For example “Tâ��ms” => “Teams”, but with that extra something added in for visual highlight (or something). So what was a programmer […]

Aug
22
2011

How to Import an ExpressionEngine Blog into WordPress

EE to WP

I’m sure by now that most of you have seen my post on how I feel about ExpressionEngine (here), so this post is a natural follower!  Today, we’re going to talk about migrating your content from ExpressionEngine to WordPress. I spent quite a bit of time working through EE’s poorly detailed instructions on how to export entries before I decided to just get my hands dirty.  Mind you, this post is only applicable to you […]

Aug
11
2011

JavaScript Close Window AND Refresh Parent

Earlier today I was working with complex PHP function to update values in a database, within a popout window.  The function worked flawlessly (naturally 😉 ), however I was looking for a way to have immediate display feedback on the parent page. Enter the JavaScript close window refresh parent script… <a id="actions" href="#" onClick="window.close();window.opener.location.reload();">Close Window</a> Looking for more?  Sorry!  That’s it for this crafty little function.

Jul
21
2011

Simple (Advanced) Click Tracking Using PHP and MySQL

Track clicks using PHP

On a recent project, I was asked to record the pages that each user was navigating to in a secured special-purpose website.  Initially it seemed daunting, however I recalled a script I’d written to track email open rates using PHP. I am generally disinterested in maintaining a database table of pages, along with a second table of clicked links as I find it to be very inefficient, so I opted to create a simple pass-through […]

Jul
18
2011

Exploding a String using Multiple Delimiters Using PHP

Php Array output

Updated February 12th, 2013 to reflect Dave’s comment function below- A++ for simplicity! function explodeX( $delimiters, $string ) { return explode( chr( 1 ), str_replace( $delimiters, chr( 1 ), $string ) ); } $list = ‘Thing 1&Thing 2,Thing 3|Thing 4’; $exploded = explodeX( array(‘&’, ‘,’, ‘|’ ), $list ); echo ‘<pre>’; print_r($exploded); echo ‘</pre>’; Earlier today, I was looking for a simple function to explode text that was contained in string format to be output […]