Calculate and highlight the differences between strings of text with PHP

php-differences

I was updating a CMS recently to archive various versions of data. If you’ve ever dealt with quality and version management you would appreciate the need to record all changes to specific text for the purpose of quality assurance. In my case, I needed to accomplish four tasks: Record specific changes to the published version [...]

Include Twitter Data on your Website

twitter-data-website

Every application I build now is littered with various types of functionality that links them into different social network. If you’re reading this post it’s unlikely I’ll have to educate you on the merits of plugging your website into the social lives of your readers. What follows is some code that will help you integrate [...]

Randomly select rows from a LARGE database with MySQL

database

I have a particular database with over one million rows and was required to extract 10 random rows for inclusion on a page that featured products indiscriminately. My initial query looked a little something like this: SELECT id FROM table WHERE something = something ORDER BY RAND() LIMIT 10; The problem with a large table [...]

Force the Download of a File with PHP

force-download

I’ve recently created a large number of websites where I aggregate podcasts and provide a detailed backend subscription and collaboration platform for both publishers and content consumers. I’ll no doubt post details on what I’ve done (and how I’ve done it) another time, but the project(s) forced me to consider a number of issues that [...]

Zip a file or files with PHP

zip

I provided a simple function a few days ago that would unzip a file using PHP. As is usually always the case, it was followed up by a few emails asking for the best method of zipping a file or files. As it turns out, I’ve worked through some ZIP classes over the last few [...]

Generate a Word Cloud from database values or array using PHP

twitter-word-cloud

A Word Cloud is a visual representation of elements or information depicted by the size or colour of a word. Popularised in social media circles, they’ve gained popularity over tables and graphs because they immediately and visually illustrate the weight or value of information in a way that can give people an immediate appreciation of [...]

Unzip a file with PHP

unzip

I received an email yesterday from a gentleman that had some issues related to yesterday’s post, “Working with CSV text files & PHP“. He had a situation where he would – literally, every single morning – download a zipped CSV file containing daily financial data from a remote server. He would then extract the contents [...]

Count the number of times your page is Tweeted via the TweetMeme API

tweetmeme

TweetMeme is an excellent site that offers various types of Twitter-based social integration to your website. They’re particularly relevant when it comes to finding current news of interest because they measure the number of times a certain website has had their story published or tweeted to Twitter. Those stories that have the most tweets are [...]

Cache Your Website with PHP (in 1 minute)

If you render webpages dynamically (using PHP) that are used to display relatively static websites or content, you may want to consider caching the page for a period of time. It’s particularly useful if your static website makes a large number of database queries or integrates external content. Caching will reduce the time it takes [...]

Google’s Weather & other Secret API’s

google-weather-pic

A very simple means of extracting weather information for inclusion in your website is via a very unknown Google weather API. The API will return weather in a very digestible XML format that you can easily parse for inclusion on any page. The API requires no key and is seemingly unsupported. The Code <?php $xml [...]

Calculate the distance between two geographical points with PHP

As a pilot by trade, and as somebody that builds a lot of aviation based applications, it was handy coming across a function that calculates the distance between two points based on longitude and latitude. I’ve just used ‘elements’ of this PHP code in an Android based application I’m working on. The function, originally published [...]