我修复它...(y)
<?php
$pattern = '/^\d{4}$/';
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db('regex_field')) {
die('Could not select database: ' . mysql_error());
}
$result = mysql_query('SELECT date_format FROM date');
$date = array();
$newdate = array();
while ($date_row = mysql_fetch_assoc($result)) {
$date[] = $date_row;
}
foreach($date AS $key => $value) {
$newdate[$key] = $value['date_format'];
}
foreach($newdate as $key => $value) {
$testexample = @preg_match($pattern, $value, $matches);
if($testexample == true) {
echo "Example & Pattern Match";
exit;
}
}
echo "Example & Pattern MisMatch";
mysql_close($link);
?>