检查变量是否高于数组php中的项



我想检查变量是否大于或等于数组中的项。

我试过多个for循环,但它们只是一堆又一堆。我只需要得到日期,例如:01-01-2005/01-01-2006将这两者与今天的日期进行比较,并检查今天的日期是否大于或等于书的日期。如果这本书是旧的,那么今天的日期做一些代码

foreach ($user_out as $userOut) {
    $userOut_id[] = $userOut['user_id'];
    }
    $userOut_id_implode = implode(',',$userOut_id);
//loop through each element from the tocomet able
$dateOfBook = [];
$today = date("d-m-Y");
foreach ($out as $outs) {
    $datum = $outs['released'];
    //gets the date of the selected book.
    $bookDate = date("d-m-Y", strtotime($datum));
    $dateOfBook[] = $outs['released'];
    //gets the name of the author
    $author_name = $outs['author'];
    //gets the title of the book
    $book_title = $outs['book_title'];
    $today = strtotime($today);
    $bookDate = strtotime($bookDate);
    //checks if today is equal or smaller then the bookdate 
}
$today = date("Y-m-d");
$y = count($dateOfBook);
for($x = 0; $x < $y; $x++){
    echo $x;
};
if($today >= $dateOfBook($x)){
    do stuff
}
$dateOfBook = [];
$today = date("d-m-Y");
$flag = 0;
foreach ($out as $outs) {
    //gets the date of the book out of the database 
    if($today >= $outs['released']){
        $flag++;
    }
    $dateOfBook[] = $outs['released']; # is this necessary?
}
if($flag){
   # do something
}

相关内容

  • 没有找到相关文章

最新更新