How to Divide an Array into Chunks in PHP
If you have a single-dimensional array, and want to break it into chunks, you can use the array_chunks method. It takes 3 arguments: The input… Read More »How to Divide an Array into Chunks in PHP
If you have a single-dimensional array, and want to break it into chunks, you can use the array_chunks method. It takes 3 arguments: The input… Read More »How to Divide an Array into Chunks in PHP
If you have some HTML input submitted from a user to your application, before saving it to the database, you may want to strip all… Read More »How to Strip Script Tags in PHP
Below is a quick and easy way to recursively delete all files and folders in a given path using PHP.
If you have a busy PHP driven website and don’t want to make constant queries to the database for each user that will see the… Read More »How to make a disk cache using PHP
Let’s take a really common example. Say we want to follow redirects with cURL for google.com. It is common to curl follow redirect a URL.… Read More »How to Follow Redirects with cURL for CLI or PHP
PHP is a powerful scripting language created for the web. It has come a long way since it’s initial inception in 1994. It was originally… Read More »How to build a website quickly using PHP
Sometimes you will need to retrieve the GET variables passed into the current page URI or you will have a URL string to work from… Read More »URL GET vars to PHP Array
There are times when you want to remove a specific HTML tag from an HTML block of text. This could be an anchor(<a/>>) or an… Read More »Remove specific HTML tags using PHP
I often need a quick and easy few lines to retrieve some data from MySQL using Joomla without all the MVC nonsense that usually goes… Read More »Let Joomla and MySQL interact!
I was busy with a custom component in Joomla, and it stored it’s own user_details based off of the main users table, but if the… Read More »Refresh User Data in Joomla
Sometimes you need to extract multiple email addresses from a string and the following function will make all your dreams come true. ..and this is… Read More »Extract email addresses from a string – PHP
Ever wanted to have a dropdown that automatically showed the current year and the few years before it? This is a quick and easy way… Read More »Make a dynamic year dropdown using PHP
Recently I had to create a code/username maker to fit into a certain type of pattern so that all “broker codes” (as they were called)… Read More »Pad a string with zeros using PHP
You heard it right! split() is officially a deprecated function. That means that you can still use it if you are really brave and it… Read More »Function split() is deprecated in PHP
It’s really very simple to convert times in different timezones using the following function. As you can see, it takes 2 arguments, $datetime which is… Read More »DateTime conversion function using PHP
With the following function you can easily convert an integer containing seconds to a nice days, hours, minutes, seconds string or array. To use the… Read More »Convert seconds to days, hours, minutes, seconds in PHP
If you would like to get the amount of hours between 10:00 and 12:00 then use this!
It’s very simple to get the difference in hours using PHP
A common error which occurs with foreach loops is the standard “Invalid argument supplied for foreach()” whch gets thrown up as a warning. This can… Read More »Warning: Invalid argument supplied for foreach()
I usually store data from a textarea directly to the database as is, then once I retrieve it back into HTML I use that lovely… Read More »PHP nl2br on one line
If you are having problems with a string that keeps adding a line break when output from PHP to HTML then the following code will… Read More »Remove all linebreaks in PHP
Would you like to restrict PHPMyAdmin from being accessible to the whole world? Firstly you need to SSH into your box if you are not… Read More »Restrict PHPMyAdmin to IP Address
I needed to do some work on a WordPress site a little while ago and all the admins were French – and I cannot speak… Read More »WordPress wp-admin use different language for user
If you would like to replace all the spaces in an HTML string with so that you can render it out to the browser… Read More »Replace all spaces in HTML with except in HTML tags using PHP