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- 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 example, all [...]



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 is grab.php
The following code [...]



Maruf scribbled this post.
1
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
$date = "1998-08-14";
$newdate = strtotime ( ‘-3 day’ [...]



Maruf scribbled this post.
11
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, I [...]



Maruf scribbled this post.
3
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.
8
PHP
Nov 2nd, 2008
Image frame
2-Dimensional Arrays In PHP

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 really does start to make sense. Each time I play with arrays I seem to learn something new.
Here’s just a quick reminder to myself of [...]



Maruf scribbled this post.
0
PHP
Oct 7th, 2008
Image frame
PHP- Count Files In A Directory

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 like everything to be automated so there is very little input from a human to make things work. To help make the thumbnail image gallery completely [...]



Maruf scribbled this post.
9
PHP
Sep 6th, 2008
want a website, do ya?

latest projects

Image frame
RG Active
view site- RG Active
Image frame
Property Investment Project
view site- Property Investment Project

latest scribbles

latest comments

zurin Gravatar frame
zurin said
hi, i’m having problem with this function. it works fine...
Karlos Gravatar frame
Karlos said
Awesome awesome awesome :) Just started re-designing...
satheesh Gravatar frame
satheesh said
It solved my problem. Thank you. Is it possible to get the...

blog categories

Get a free quote