so I am running through an array containing different types of fruit, by using foreach. Every time a fruit of that array matches a fruit within the string of $this-field (for example apples), the fruit shall get echoed.
Problem What happens instead is that this code will simply list EVERY fruit within $fruits. It does so even if I erase the whole strpos part and replace it by whatever I want like $test or something. It is like the conditioning within the if-loop is just getting totally ignored for some reason and I can't wrap my head around it. Please take a look at my code below.
foreach ($fruits as $fruit) {
if (strpos($this->field('has_apples'), $fruit) !== false ) {
echo $fruit;
};
}
Aucun commentaire:
Enregistrer un commentaire