You know how Dribbble shows a color palette for each shot users upload? They always look perfect right? Here’s a tool that can give you the same quality results using pure JavaScript. I played with Color Thief a few months ago but surprisingly never posted about it. For me, something that’s easy to use and has consistently great… Read More


Have you ever needed to send a PHP variable, array, or object to JavaScript? It can get complicated trying to escape the output properly. Here’s a way that always works—no escaping necessary. Let’s say we have the following variable in PHP:

And we want to pass it to a JavaScript variable called name. Here’s the… Read More


Managing a RESTful application in PHP can become a headache if you are new to REST but I have developed a reusable class function that will save you hours of development time shown below.  Feel free to reuse it.

 … Read More


Sometimes you might need to create a variable in PHP having the name of some value.  Below is the easiest way to accomplish this need.

 … Read More


Using PHP shorthand IF/Else statements are a great time saver and help make your code look neater.  Here is a collection of examples I often use.

 … Read More


When you export JSON form PHPwhich contains data from an “unclean” data source you must enforce UTF-8 upon the data that will be added into your JSON structure.  Below I’ll show an example of exporting JSON and enforcing UTF-8 upon each record data entity.

 … Read More


Sometimes you need to export a collection of data for use to another system.  One of the easiest ways is to export it to XML as it is widely accepted as a data exchange format and standard.  PHP makes creating and exporting to XML very easy.  Below I’ll show you an example where I am exporting… Read More


I had to process a lot of Word .docx files into readable content for use in a searchable database.  Docx files are basically xml files in a zipfile container (as described by wikipedia).  Here is my solution, it’s pretty straight forward.  Just pass in the server file path to the read_docx() function and it will… Read More


Validating Email Addresses is one of the more elusive patterns to define, but this pattern will match 99.99% of all email addresses in actual use today.

A further change you could make is to allow any two-letter country code top level domain and only specific generic top level domains. This regex filters dummy email addresses… Read More


I develop a lot of data parsers and continuously run into composite mailing addresses that require to be split into their meta collections. The following Regex pattern will reformat these two style addresses into XML tag elements. SAMPLE ADDRESS DATA: 1200 Ocean Rd., Narragansett, RI 02882 1200 Ocean Rd., Narragansett, RI 02882-1234 FIND PATTERN USING… Read More