View Single Post
Old 22-08-2008, 09:57   #53 (permalink)
DaveChild
Registered User
 
Join Date: Aug 2008
Posts: 8
Quote:
Originally Posted by freelancr
Validate E-Mail Address:

That email validation function was originally from my site, and is a bit out of date now (especially since the opening up of the TLD system). I rewrote the code and released it a little while ago under an open source license - see addedbytes.com/blog/email-address-validation-v2/

Here's a couple of functions I find useful. They add and remove variables from querystrings (great if you're dynamically building querystrings, especially on listing pages with listing options).

Add a Variable to a Querystring

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


Remove a Variable from a Querystring

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

  Reply With Quote