Category Archives: Programming

Tips, tutorials and techniques surrounding programming in many languages such as PHP, MySQL, Javascript, jQuery and more.

Calculate Time Difference Between your Users And Your Server

People access your site aren’t always in the same timezone as you are. Now perhaps you would like to determine what the time is for a user in a different country. Then here is a quick way to find this information out. This example is very useful if you simply want to fetch your clients [...]

PHP stdin – Reading user input from command line in PHP

In C++ it is called cin, and in perl it is $variable = <STDIN> however what is the equivalent of cin and STDIN for PHP? Well in PHP is is similar to perl in that we use php://stdin to read a user’s input from the command line. It is pretty straight forward and hopefully the [...]

Increase PHP Memory Limit in htaccess, apache or in a php script

Most of us have come across this error: “Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate yyy bytes) in ….” in the php error logs. In php, running out of memory in usually a sign that your php script is not too well written or has a bug or two in [...]

PHP Pear – Installing Pear and Pear Packages

What is PEAR? PEAR is an acronym for PHP Extension and Application Repository. PEAR is a massive repository for PHP code. It provide easy access to hundreds of classes that can be implemented into your existing PHP project. It saves you time since you won’t have to write anything from scratch and you can simply reuse [...]

Quickest Way To Remove Empty Elements From A PHP Array

Here I will show you the quickest way to remove empty values from an array. The first way is slow but the most logical way of approaching this. Luckily the second example is the quickest and also pretty simple way. Use the second way, trust me, you will love it. The slow but simple way [...]

Output Ajax JSON Header in PHP

Overview of JSON JSON http://www.json.org/ is an acronym for JavaScript Object Notation. It is essentially a way of exchanging data between a source and destination using name/value pairs. Commonly used when transferring data from a database to a website using AJAX. Generating a JSON object using php is pretty simple (although it won’t be covered [...]