I have a multidimensional array:
array(3) {
["checkIn"]=> array(0) {}
["code"]=> array(0) {}
[0]=> array(2) {
["checkIn"]=> string(10) "2021-02-02"
["code"]=>string(10) "00Q4K00"
}
}
which I initialize in this way:
$array= array(
'checkIn'=>array(),
'code'=>array()
);
and so I value:
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$array[] = array('checkIn'=>$row['checkIn'], 'code'=>$row['code']);
}
I can't figure out how to extract 'code' if '2021-02-02' is present:
if ( in_array('2021-02-02', array_column($array, 'checkIn')) ){
echo code??
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…