Hiya!
Pretty new to php and I am trying to fathom the whole looping through an array thing. Unfortnately my book does'nt answer questions. Could someone help?
I have a an array called $PetTreatment holding 5 values like so:
$PetTreatment[] = "LeuJab";
$PetTreatment[] = "FluJab";
$PetTreatment[] = "Worm";
$PetTreatment[] = "Flea";
$PetTreatment[] = "NeuJab";
echo "<p>Your Pets treatments are:</p>";
foreach ($PetTreatment as $treatments){
echo "<p>$treatments</p>";
}
I can echo out the name of the treatments working through a foreach loop, and $treatments temporarily holds each value stored array for the time that the loop is looping.
The problem I have is I want to compare a number of these values at once. So if, for instance there are some variables like this:
$Flu = "FluJab";
$Leu = "LeuJab";
$Neu = "NeuJab";
$Flea = "Flea";
$Worm = "Worm";
I can compare all the values in the array at once with each of the variable values specified above. For example:
If ($treatments == $Flu and
$treatments == $Leu and
$treatments == $Neu and
$treatments == $Flea and
$treatments == $Worm){
echo "You have all the treatments necessary!";
}
Can't seem to get my head around this.
Obviously all the values are there in the array, but only one is output at a time, and I cannot figure out how to check the contents of the array as a whole.
Can someone help?