I don't know where you're getting $date
you need 'date'
, and you're not using $array
anywhere in the $c
assignment. It can be shortened, but using your code, just check the next
element:
foreach($array as $value) {
$b = $value['date'];
$c = next($array)['date'] ?? false;
if($b == $c) {
echo 'Yes';
}
}
If they are sequential integer keys then you can do it your way, just check that $key+1
is set:
foreach($array as $key => $value) {
$b = $value['date'];
$c = $array[$key+1]['date'] ?? false;
if($b == $c) {
echo 'Yes';
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…