我有一个类似这样的数组:
[
{
"date":"2015-07-10",
"count":"1"
},{
"date":"2015-07-11",
"count":"3"
}
]
以下是由Eloquent查询提供的:
$posts = Post::select(array(
DB::raw('DATE(`created_at`) as `date`'),
DB::raw('COUNT(*) as `count`')
))
->where('created_at', '>', Carbon::today()->subWeek())
->groupBy('date')
->orderBy('date', 'DESC')
->get()
->toArray();
我怎样才能检查某个日期是否已经在数组中?我已经尝试了下面的方法,但它返回
false
(即该值不在数组中,尽管实际上它在数组中):return in_array("2015-07-10", $posts);