Stop waiting, start array dereferencing in PHP now!

Ever since I started programming object oriented PHP I’ve been using function chaining and function dereferencing. But there is another thing I’d like to be able to do that was added to the PHP trunk over 8 months ago that still hasn’t made it to the current release. The function I’m referring to is array dereferencing. Because I got tired of waiting for this to be included in PHP 5.4 or 6 I decided to write a little code snippit for this exact purpose.

Ever since I started programming object oriented PHP I’ve been using function chaining and function dereferencing. But there is another thing I’d like to be able to do that was added to the PHP trunk over 8 months ago that still hasn’t made it to the current release. The function I’m referring to is array dereferencing. Continue reading “Stop waiting, start array dereferencing in PHP now!”

How to zero fill a number in PHP

A while ago I needed to automatically zero fill a number for a quoting system I was working on. I decided to browse the internet to search for a simple code snippit but I could only find code with a while loop that would keep adding zeroes untill the desired string length was reached. Although this seemed okay, I realized it could be done much cleaner, and most important, less draining for system resources. So I wrote my own function.

A while ago I needed to automatically zero fill a number for a quoting system I was working on. I decided to browse the internet to search for a simple code snippit but I could only find code with a while loop that would keep adding zeroes untill the desired string length was reached. Although this seemed okay, I realized it could be done much cleaner, and most important, less draining for system resources. So I wrote the following function. Continue reading “How to zero fill a number in PHP”

Use PHP to get the number of items for a domain on Digg.com

Whilst working on my semi-automated SEO scan I wanted to get the number of listings for a given domain on some social bookmarking websites. Of course Digg.com is a very well-known and widely-used bookmarking website but sadly they don’t offer a nice XML or JSON API to check the number of listings. That’s why I wrote the following code to retrieve this number.

Whilst working on my semi-automated SEO scan I wanted to get the number of listings for a given domain on some social bookmarking websites. Of course Digg.com is a very well-known and widely-used bookmarking website but sadly they don’t offer a nice XML or JSON API to check the number of listings. That’s why I wrote the following code to retrieve this number. Continue reading “Use PHP to get the number of items for a domain on Digg.com”

Web services and backward compatibility

About a year ago I was asked by a client to update their existing web service because of some changes in the way they wanted to process their sales data. Luckily this client has always understood the importance of a Service-Oriented Architecture ( SOA ) since they deal with large amounts of resellers who need to access, edit and create data. All I had to do was apply the changes to their web service. Continue reading “Web services and backward compatibility”

Never having to use $_GET or $_POST again

Since the release of PHP 5.2 you can easily fetch and sanitize data send via superglobals in a safe manner. You can replace your current sanitation class with this API.

I completely missed this great new feature build in PHP 5.2 since I haven’t been using much vanilla PHP lately due to my preference for CodeIgniter. Continue reading “Never having to use $_GET or $_POST again”