A while ago I asked a question and got a few answers, so I thought I would 
toss this out there as a follow up.  I'm going to be using this to return 
filtered regexp values for a user interface.

I haven't had a chance to enter this into my code yet, so if anyone sees 
something wrong please hammer away, otherwise I hope it helps save some one 
some time.

function regexp_sanitize($string,$regexp) {
    if(isarray($string)) {
        foreach($string as $key => $value) {
            $count = preg_match($regexp,$value,$matches) {
            if($count != 1) {
                $result[$key] = FALSE;
            } else {
                foreach($matches as $toss => $matchval) {
                    $result[$key] = $matchval;
                };
            };
        };
    } else {
        $count = preg_match($regexp,$string,$matches);
        if($count != 1) {
            $result = FALSE;
        } else {
            $result = $matches[0];
        };
    };
    return($result);
}; 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to