Apologies for the newbie question but I'm relatively new to PHP and want to do something fairly simple... If I have an array of keys & values (pears):
$arrayOfPears = array(
"Green Anjou" => [ 7,
"plump",
"ripe",
"juicy",
"green"
],
"Bartlett" => [ 2,
"moderately plump",
"unripe",
"sweet",
"greeny-yellow"
],
"Comice" => [ 3,
"rather plump",
"ripe",
"blinding",
"deep-green"
],
"Plum" => [ 6,
"rotund",
"over-ripe",
"sweet",
"purple",
"not really a pear, as far as I'm aware"
]
);
I am able to access a specific pear's value and use it for a comparison operation. For example:
if($arrayofPears['Comice'][2] == "ripe") {
$nibble = true;
return $nibble;
}
Does return a true $nibble. However, what I would like to be able to do is check first if the Comise key is present in the array, before I try to enter the if statement and find out if I get a true $nibble.
So... how do I check if any 'Comice' are present in this situation, before committing myself to enter the conditional?
Aucun commentaire:
Enregistrer un commentaire