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.
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.
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.
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.
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.
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.
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.
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.