How to automatically force a cache refresh on CSS and JavaScript files with PHP?

Posted by on Dec 30, 2012 in CSS, PHP | One Comment

There is your client, complaining that they can’t see the changes you just made to their website. You explain them that they need to delete their browser cache in order to properly visualize the modifications. They said they don’t know how, and this is when you lose your patience and decide for a more radical […]

Mobile browser detection for WordPress – embedded is_mobile() function

Posted by on Mar 7, 2012 in PHP | 5 Comments

Lets face it. Responsive design is here to stay and it is the solution to all of our nightmares regarding mobile web design. For those who are not aware of this technique, I invite you to read my other post where I explain what it is. But lets get to the point. Sometimes we need […]

Finding unique array combinations with PHP (permutations)

Posted by on Jun 23, 2011 in PHP | 4 Comments

I was developing a website where people would place horse bets and the system should be able to calculate all the possible permutations based on the user selection. That means: finding all the possible combinations in a two dimensional array. I found a couple of functions but none of them would keep the array keys […]

Error Validation Class for CodeIgniter Reactor 2.0

Posted by on May 3, 2011 in CodeIgniter, PHP | 3 Comments

CodeIgniter lacks of an error handling class for custom errors. The Form Validation class is very nice for forms, the logs are pretty useful as well, but what happens when we need to handle our own errors?. Currently there is no official solution for this so I decided to take the matter in my own […]

Exporting your MySQL table data with PHPExcel + CodeIgniter

Posted by on Mar 8, 2011 in CodeIgniter, PHP | 12 Comments

Most of the time my clients need to download data from their database tables. Exporting to CSV is a pain in the rear for users and it leads to confusion (you know the colon and semicolon stuff). Today, I decided to make a very small controller that is portable and efficient for exporting full MySQL […]

Facebook PHP SDK and CodeIgniter for basic user authentication

Posted by on Feb 24, 2011 in CodeIgniter, PHP | 205 Comments

With CodeIgniter 2, plugins are no longer an option. Usually you would just add the Facebook PHP SDK as a plugin and you were good to go, but now, you need to make a little modification to the SDK in order to use Facebook Connect on your CodeIgniter application. Lets start by explaining what is, […]

Read Word documents with PHP (up to Word 2003)

Posted by on Feb 10, 2011 in PHP | 8 Comments

Reading Word documents with PHP on a Linux box can be a real pain. It requires DOM which is only available on the Windows platform. However, Unkwntech from Stack Overflow made quite a nice function to read Word documents and extract its information. It will only parse text content, but it is enough for most […]

Detect mobile browser/user agent with PHP (iPad, iPhone, Android, BlackBerry, WP7 and others)

Posted by on Feb 2, 2011 in PHP | 79 Comments

With all this load of smartphones and tablets, it is mandatory for us as developers to optimize our content as much as possible so everybody can see it, no matter what device they are using. This is why I wrote a small but powerful function to properly detect a wide range of mobile devices and […]

$_GET parameters on CodeIgniter

Posted by on Dec 13, 2010 in CodeIgniter, PHP | One Comment

Yeah, it is a much discussed topic in every CI forum. I needed to set up a payment gateway and it was mandatory to receive the gateway response via $_GET, so I decided to do an investigation on the matter and this is what I came up with.

CodeIgniter 2.0 new FTP class “download” method

Posted by on Nov 25, 2010 in CodeIgniter, PHP | 3 Comments

I needed to download some files from a remote FTP server and the store them in my website. The usual way would be to download all the files to my computer and then upload them to my website. In CodeIgniter 1.7.2 you would have to do this, however, the new CodeIgniter 2.0 has a new […]

Trim long texts by words in PHP

Posted by on Oct 14, 2010 in PHP | No Comments

We don’t like reading chopped sentences like “Star Wars Old Republic is be….”. It looks fugly. Usually, when trimming text you will go with substr(), but there is a much better way to do it, and believe me, you trimmed text will look so much better than before.

HTML Table Class on CodeIgniter 2.0

Posted by on Aug 31, 2010 in CodeIgniter, PHP | 3 Comments

CodeIgniter 2.0 is coming out soon, so lets start studying the changes done to the HTML Table Class in the dev-release. One of the most requested features was the ability to set tag attributes to individual cells. On CI 2.0 this is completely possible, however, since the documentation is not fully updated yet, I decided […]

Fixing UTF-8 encoding problems on MySQL queries with PHP

Posted by on Aug 24, 2010 in MySQL, PHP | 4 Comments

It happened to me a lot of times, I had my connection set to UTF-8, my database was UTF-8, even my tables and every single field, however, for some reason, the information I updated in phpMyAdmin wasn’t being displayed correctly on my website and the information edited on my website wasn’t being displayed correctly in […]

Twitter feed on your website with cURL and PHP

Posted by on Aug 15, 2010 in PHP | 3 Comments

Pulling code from here and there, I gathered enough information to create a small function that allow you to pull your Twitter feed and display it in your website. What you do is basically call the function and pass a couple parameters. The styling can be done with CSS.

Alternate row colors with PHP

Posted by on Aug 10, 2010 in PHP | 3 Comments

I know there are several ways to accomplish this, however, of all the ones I’ve tried, this is the shortest so far: So, if you make two classes, row1 and row2, each with a different background color, the result will be alternated row colors in whatever you’re doing. Very useful for long lists. Update: you […]

Load More