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