如何制作日期范围搜索功能

时间:2015-07-27 01:38:13

标签: php search date-range

这是我的脚本,显示了使用关键字

从csv文件中搜索数据的搜索框
<?php
$file  = fopen('aws.csv', 'r');
$output ='';
if (isset($_POST['searchVal'])) {
$words = $_POST['searchVal'];

$words = array(preg_replace("#[^0-9a-z]#"," ",$words));

$words = array_map('preg_quote', $words);
// The argument becomes '/wii|guitar/i', which means 'wii or guitar, case-insensitive'
$regex = '/'.implode('|', $words).'/i';

while (($line = fgetcsv($file)) !== FALSE) {  
    list($name, $age, $hobbies) = $line;

    if(preg_match($regex, $age)) {
        $output .=  "$name, $age, $hobbies<br/>";
    }

    }
}       
?>

<form action="search1.php" method="post">
    <input type="text" name="search" placeholder="Search">
</form>

<?php echo $output; ?>

现在我想制作范围搜索功能,例如我希望搜索20150727-20150730之间的日期... 20150727意味着2015年7月27日

0 个答案:

没有答案