Tim TrottTim TrottJust live

PHP

The scripting language of choice for most web designers. It’s free, easy to learn and above all there are many thousands of scripts and packages that you can run (also free!). These articles feature code snippets, tips and techniques and full scripts to help you advance your PHP powered website.

 

PHP Function to Import CSV to an Array
31/10/2013PHP
How to import CSV file into a PHP array using PHP's fgetcsv function. The array is associative so you can access values by the column heading from the CSV.
PHP Performance Tuning with XDebug
15/11/2012PHP
PHP Performance Tuning is a good way to waste the hours of time to get milliseconds back. XDebug is the swiss army knife of PHP performance tuning, and enables enhanced diagnostics, debugging and performance profiling for all PHP applications. This article will show you how to get set-up and start profiling your scripts with XDebug.
Everything should be made as simple as possible, but no simpler.Albert Einstein
Add YouTube Videos to phpBB
10/12/2009PHP
Bulletin board software such as phpBB will not allow you to use the embed code provided by YouTube. This simple tutorial will show you how you and your visitors can link embed videos in posts with a very simple bbcode tag.
Blocking Website Access by Country with PHP
20/04/2009PHP Security & Privacy
A while back one of my websites came under a massive attack receiving an additional 1000+ hits per day, all malicious construction and all from one particular country. Since I was fast approaching my allocated bandwidth limit I had to take action to stop them accessing the site, and fast!
How to Add Three Dots (Ellipsis) to a Long String with PHP
20/04/2009PHP
Ellipsis are a series of three dots that indicate an intentional omission of a word, sentence or whole section from the original text being quoted. Here is a simple little function in PHP that will truncate a string after X number of characters and replace it with three dots (or whatever you specify). This is useful when showing an excerpt or a short introduction.
Timing PHP Script Execution
07/02/2009PHP
Another of my widely used PHP snippets is this timing function, which can be used to time a whole script execution, or a single function. This is especially important for optimizing script performance and reduction of page load times.
Format a Number as File Size in PHP
24/01/2009PHP
This function will format a given number into a pretty file size, for example convert 1000000 to 1MB, 3523 to 3k and so on.
Get First Sentence from a String in PHP
24/01/2009PHP
This quick PHP snippit will return the first sentence of a specified string. Very useful for generating post or page abstracts, extracts or descriptions.
Protecting MySQL from SQL Injection Attacks with PHP
20/06/2008PHP SQL Databases
A guide on how to properly protect your MySQL database from SQL injection attacks by using a little common sense, good programming practices and PHP.
Regular Expressions Explained
18/10/2005PHP
I love it when people say "a simple way to do xyz is to use regular expressions" and then offer what amounts to a string of indecipherable hieroglyphics to answer the question. However, once you know how to leverage the power of regular expressions, they can be very useful tools.