poncho
01-13-2006, 10:19 PM
Hey guys,
I have a problem and hope someone can point me in the right direction :-)
I've put this test function together to find keys that pass the regex and append them to the $count array, but it seems that I'm not filtering the keys properly.
$Rexex = '/^(eventDates)\s?([0-9]+)$/';
function countDates ($form_result) {
$count = array();
while(list($key, $val) = each($form_result)) {
if(preg_match($Regex, $key)) {
$count[$key] = $val;
}
}
return $count;
}
print_r(countDates($_GET));
Calling this with "?eventDates1=123&eventDates2=234&startTime1=345" should be giving me back the following, but it's just giving an empty array:
Array
(
[eventDates1] => 123
[eventDates2] => 234
)
Obviously, the if preg_match isn't returning true, but I have no idea why not. The string 'eventDates1' passes the regex no problem and so do the other keys in the $_GET array except for startTime1.
Any help would be appreciated.
Cheers;
Poncho
I have a problem and hope someone can point me in the right direction :-)
I've put this test function together to find keys that pass the regex and append them to the $count array, but it seems that I'm not filtering the keys properly.
$Rexex = '/^(eventDates)\s?([0-9]+)$/';
function countDates ($form_result) {
$count = array();
while(list($key, $val) = each($form_result)) {
if(preg_match($Regex, $key)) {
$count[$key] = $val;
}
}
return $count;
}
print_r(countDates($_GET));
Calling this with "?eventDates1=123&eventDates2=234&startTime1=345" should be giving me back the following, but it's just giving an empty array:
Array
(
[eventDates1] => 123
[eventDates2] => 234
)
Obviously, the if preg_match isn't returning true, but I have no idea why not. The string 'eventDates1' passes the regex no problem and so do the other keys in the $_GET array except for startTime1.
Any help would be appreciated.
Cheers;
Poncho