I have an array and I am checking if a value exists in the array using in_array(). However, I want to check only in the ID key and not date.
$arr = ({
"ID":"10",
"date":"04\/22\/20"
},
{
"ID":"20",
"date":"05\/25\/20"
},
{
"ID":"32",
"date":"07\/13\/20"
});
So in this example, the condition should not be met since 25 exists in date, but not in ID.
if (in_array("25", $arr)) {
return true;
}
in_array()function. Like,in_array("25", array_column($arr, 'ID')). Clean, yes. Efficient, not much.