jeudi 9 août 2018

Why does my simple "if" not work? PHP

So, I'm trying to do something pretty simple: to check if a number equals another number - but for some reason it just doesn't want to work.

$exhibitions = "20,21,24";
$parent = "[[*parent]]";
$id = "[[*id]]";

if ($id == 5) {
    $chunk = "listExhibitions";
}
if (stripos($exhibitions, $parent) == TRUE) {
    $chunk = "Exhibitions";
}
return "[[$" . $chunk . "]]";

It's the first "if" that I'm trying to get to work. If I put an ! before the == then the page shows the "listExhibitions" chunk - but I need it to do so when the id equals five. I've tried putting ' ' around the number too. Also, when I've simpy outputted the $id, the number 5 shows up.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire