Scribbles about PHP

For the most part, we favour PHP as the scripting language of choice. Not particularly because we think it’s the best scripting language out there, but because that’s what we’re trained in. For that reason, we’ve dedicated this PHP section, where we’ll be indulging ourselves with PHP tips, tricks and banter

Image frame
PHP – Capitalize First Letter Of Every Sentence For Proper Formatting

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 example of what the code will do… Before: Hello This Is An Example Of A Sentence Which Has Odd Capitalization Which You May Want Fixing. [...]



Maruf scribbled this post.
1
PHP
Jul 31st, 2010
Image frame
PHP – Populate Date Dropdowns – HTML Forms

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, so i’m forever retyping it! To generate the date dropdown fields shown above, you could hardcode the values, like this…. View Code HTML1 2 3 [...]



Maruf scribbled this post.
0
PHP
Jun 10th, 2010
Image frame
PHP- Using Preg_replace To Strip Date From URL

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 can be used to resolve a load of tricky regular expression issues. The Scenerio A client recently changed permalink structures for his entire website. For [...]



Maruf scribbled this post.
0
PHP
Sep 18th, 2009
Image frame
PHP- Call Action In A Loop On A Set Multiple Value

PHP- Call Action In A Loop On A Set Multiple Value

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 a loop, and I want to call a certain action on every 5th loop. For example, on the 5th, 10th, 15th..etc count, I want to [...]



Maruf scribbled this post.
0
PHP
Sep 13th, 2009
Image frame
PHP- Getting The Filename From A URL

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 other people want the same result. Example Ok, so we want the filename for the following page: http://www.anydomain.co.uk/page/grab.php We want to grab the filename, which [...]



Maruf scribbled this post.
2
PHP
Mar 27th, 2009
Image frame
PHP- Adding And Subtracting Dates

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 days from a date The following example will subtract 3 days from 1998-08-14. The result will be 1998-08-11. View Code PHP1 2 3 4 5 [...]



Maruf scribbled this post.
19
PHP
Jan 6th, 2009
Image frame
PHP- Check If File Exists On Different Domain

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 remembered that file_exists only checks whether a file or directory exists on the same server as the script. After I played around with various functions, [...]



Maruf scribbled this post.
6
PHP
Nov 20th, 2008
Image frame
PHP- List All Files In A Directory

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. It’s actually a very simple process in PHP and only requires a small amount of code. I’ve seen a lot of examples on other forums/websites [...]



Maruf scribbled this post.
11
PHP
Nov 2nd, 2008
Get a free quote