PHP: Function to force HTTPS

June 3, 2010

Quite often HTTPS is required for security reasons, but the question is how to force HTTPS with PHP?  Really it is quite simple. Copy the following function into your functions file and call it on top of every page that requires HTTPS to ensure it is used. function forceHttps() { $pageURL = ‘http’; if (!isset($_SERVER[“HTTPS”])

PHP: Remove empty array elements

June 3, 2010

I’ve run across a couple instances where I needed to either remove empty array elements or perform the equivalent of a trim() on PHP arrays. There are two pretty good ways to do this. The first way involves building a custom function to loop through an array and unset empty elements like so: function arrayRemoveEmpty($Array)

Typo3: Count the number of Pages, Content, and Words in your install

May 17, 2010

Ever wonder how many pages, words or tt_content element you have in your Typo3 install? I am working with two large Typo3 sites and I was curious so I wrote a little piece of code. It works really well and is super quick. Here is what the output looks like: Counting Pages SELECT COUNT(uid) AS

PHP: Count words in a MySQL column

April 27, 2010

Last week I posted a query that will return the number of words in a column of a table in a MySQL database. I was looking through a huge database and the query took a really really long time. Today I decided to rewrite it in PHP and see if it was faster. Much Much

Build a Basic Authorize.net Payment Form

March 10, 2010

Zac Vineyard wrote a great tutorial on building a basic Authorize.net payment for and connecting to their payment gateway. Zac used some of my code and was kind enough to reference me for it, and since he wrote such a clean tutorial I see no need to write my own (used my code anywho!). Check