Does it help ?
<?
$eatable=array ("fruit","vegetable","food");
$apple = "fruit";
$carrot = "vegetable";
$avacado = "food";
if (in_array($apple,$eatable)){
echo "you can eat it";
}
?>
Noerd Joeller wrote:
If apple is a fruit or a vegetable, print, "you can eat it."
Can this somehow be written in a format similar to this:
$apple = "fruit";
$carrot = "vegetable";
$avacado = "food";
if ($apple == ("fruit" || "vegetable" || "food"))
{
echo "you can eat it";
}
or do I have to list each one, like this:
$apple = "fruit";
$carrot = "vegetable";
$avacado = "food";
if (($apple == "fruit") || ($apple == "vegetable") || ($apple == "food"))
{
echo "you can eat it";
}