Enquiry Email Form

PHP Scripts, Tips & Tricks

PHP – Best Way To Get User IP Address

A lot of people rely on the $_SERVER[‘REMOTE_ADDR’] global variable to retrieve a user IP address, but there’s a better more reliable way of retrieving a vistor’s/user’s IP Address… Retrieve…

PHP Scripts, Tips & Tricks

PHP- Get URLs/Links From A String

The following function puts all URLs/links from a string into an array. The function uses the preg_match function, and looks for URLs/links with http/https. Please note, the function does NOT…

PHP Scripts, Tips & Tricks

PHP- Display Certain Amount Of Words From String/Variable

If you want to display a specific amount of characters from a string, you can use the PHP built-in function substr, but from what I’m aware, there isn’t a PHP…

PHP Scripts, Tips & Tricks

PHP- Show Your Latest Tweet On Your Website With PHP

In the archives, there’s a post that shows you how to show your latest tweet on your website using jQuery. While that method was OK, I found it rather temperamental….

PHP Scripts, Tips & Tricks

PHP- How To Show An Excerpt/Teaser From A String

Here’s a quick function that will limit the amount of words that will display from a string of words, so you effectively get a excerpt/teaser. For example, let’s assume you…

PHP Scripts, Tips & Tricks

PHP- Alternative To The Depreciated mime_content_type Function And Fileinfo Functions

You’ve probably landed on this page because you want to find the Content-type of a file by using the mime_content_type function. But when you tried using the function, you were…

PHP Scripts, Tips & Tricks

PHP- List All Directories/Folders From A Specified Location

This is a quick extension/counterpart to my existing blog post that explains how to List All Files In A Directory in PHP. But instead of listing all files, I’m quickly…

PHP Scripts, Tips & Tricks

PHP – Changing Date Format

A friend of mine has been struggling to format a date string he’s pulling out from a MySQL table. He’s just started learning PHP, so he’s still getting to grips…

PHP Scripts, Tips & Tricks

PHP – Creating A Year (date) Loop

Here’s a good/efficient way of building a loop of years from a starting point to an ending point. For example, this code will show you how to print a range…

PHP Scripts, Tips & Tricks

PHP – Capitalize First Letter Of Every Sentence For Proper Formatting

Here’s an extremely useful snippet of code that will properly format sentences with capitalization. Actually, what the code really does is capitialize every letter AFTER a full-stop (period). Here’s an…

PHP Scripts, Tips & Tricks

PHP – Populate Date Dropdowns – HTML Forms

Ok, i’m going to quickly jot down some PHP code, which dynamically populates date fields (dd/mm/yyyy) for HTML forms. I’m always using this code, but I never write it down,…

PHP Scripts, Tips & Tricks

PHP- Using Preg_replace To Strip Date From URL

This is a very specific problem I was faced with a few days ago, so I doubt many people will find it directly useful. However, the solution to this problem…

PHP Scripts, Tips & Tricks

PHP- Check If A Number Is Multiple Of Another Number

This is one of those posts that is purely a reminder for myself. It’s something so simple, but for some reason or another, I tend to forget. Suppose I have…

PHP Scripts, Tips & Tricks

PHP- Getting The Filename From A URL

Someone emailed me, asking me how to get the filename from a URL using PHP. It’s pretty easy, but I thought i’d jot it down for everyone, just in case…

PHP Scripts, Tips & Tricks

PHP- Adding And Subtracting Dates

Here’s how you add and subtract dates from one another. For example, this simple code can calculate what the date will be 2 weeks before or after 1998-08-14 (yyyy-mm-dd). Subtracting…

PHP Scripts, Tips & Tricks

PHP- Check If File Exists On Different Domain

Earlier today I needed to find out if a file exists on a different domain. Initially I used the file_exists function, but then when that threw back an error I…

PHP Scripts, Tips & Tricks

PHP- List All Files In A Directory

I’m working on a website for a client at the moment, and one of the features I need to do is display a bunch of images in a particular directory….

PHP Scripts, Tips & Tricks

2-Dimensional Arrays In PHP

I LOVE arrays. They make life so much easier and efficient. At first they can be quite difficult to get the hang of, but once you capture the basics, everything…

PHP Scripts, Tips & Tricks

PHP- Count Files In A Directory

I’ve just added a new feature to the Team page, where i’ve added a small CSS image gallery. So now you can see multiple images of the awesome BrightCherryteam! I…

PHP Scripts, Tips & Tricks

PHP: Remove Everything But Letters And Numbers – Reg Expressions

I always forget this PHP function, but I’m finding myself regularly needing it. I thought I’d just jot it down for my own reference and for anyone else who might…

Learning & sharing

This section is dedicated to PHP Scripts, Tips & Tricks, for both our own uses and for others to learn from. Sharing is caring.

Please feel free to contribute to our blog posts; perhaps even teach us a few tricks of your own. We'd love to hear your thoughts.



X