Skip Navigation

Hi. I'm Dave, the internet addict behind FeedbackFair, Cheatography and Envoy.

Tagged with "code"

You can subscribe to this tag by rss or view all tags.

Cheat Sheets

Regular Expressions (V1)

Regular Expressions Cheat Sheet (V1)

Regular Expressions are very powerful, and many people find their unusual syntax hard to get to grips with. This A4 reference serves as a guide to regular expression patterns and options.

JavaScript

JavaScript Cheat Sheet

A quick reference guide for JavaScript, listing methods and functions, and including a guide to regular expressions and the XMLHttpRequest object.

PHP (V1)

PHP Cheat Sheet (V1)

I'm fed up with having to visit php.net to look things up. This A4 cheat sheet is designed to sit by your desk and make your life easier.

Articles

Blog and Lab

PHP Querystring Functions

Adding and removing variables to and from URLs using PHP can be a relatively simple process admittedly, but I have a couple of functions I use often to make the process even less time-consuming.

Add Querystring Variable

A PHP function that will add the querystring variable $key with a value $value to $url. If $key is already specified within $url, it will replace it.

function add_querystring_var($url, $key, $value) {
    $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
    $url = substr($url, 0, -1);
    if (strpos($url, '?') === false) {
        return ($url . '?' . $key . '=' . $value);
    } else {
        return ($url . '&' . $key . '=' . $value);
    }
}

Remove Querystring Variable

A PHP function that will remove the variable $key and its value from the given $url.

function remove_querystring_var($url, $key) {
    $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
    $url = substr($url, 0, -1);
    return ($url);
}

05 December 2006   |   49 comments   |   links, code, development, url, querystring, reference, php, functions, programming, tips, variable

RSS to iCal

I have been looking for a way to convert the BBC weather feed for my area to iCal, so I can subscribe to it. It's date-based, after all, and RSS never seemed to me to be an appropriate format for subscribing to weather information. iCal always struck me as being "better" for that purpose. Of course, the BBC only have an RSS feed for local weather. What I needed was a converter.

After some hunting, I discovered that Dean Sanvitale had written a PHP script to convert RSS feeds to iCal format. However, his site (codent.com) appears to be long since abandoned and the script is no longer available from there. Fortunately, the Wayback Machine did have a copy. Dean originally released the script under a Creative Commons License which, fortunately, allows me to make the script available to download from this site (note: the script is available from this site under the same license).

So, if you're looking for a way to convert an RSS feed to iCal, this PHP script will do the job. Thanks Dean!

Source: rss2ical.txt

19 October 2006   |   15 comments   |   rss, weather, php, bbc, ical, convert, tools, web, webdev, code, rss2ical

Preload Images with CSS

How to preload images using CSS and so avoid delays with rollover effects.

Click here to read this post »

23 December 2004   |   57 comments   |   code, rollover, webdev, howto, preload, web, design, image, webdesign, images, css

View Page Structure

A tool that outputs the structure of a page. Makes working with CSS (especially resolving inheritance issues) much easier.

Click here to read this post »

12 October 2004   |   26 comments   |   imported, code, xhtml, tool, cheatsheet, design, webdesign, useful, tools, resources, css

Gunning-Fog Index

The Gunning-Fog Index is a measure of text readability based upon sentence length and difficult words in a passage.

Click here to read this post »

06 July 2004   |   7 comments   |   code, programming, php, tools, readability, language

Email Address Validation

How to validate email addresses according to ISO standards with PHP.

Click here to read this post »

01 June 2004   |   200 comments   |   code, development, email, php, programming, regex, regexp, security, tutorial, validation, webdesign