I am trying to create a conditional statement for the value of an array.
We are assigning a class randomly to an element using PHP every time the page loads. We are using the following code:
<?php $words = array('pizza','barbers','gyms'); echo $words[rand(0, count($words)-1)]; ?>
The above works fine, except we need to check the value of the random class that has been outputted show specific content for that value.
So far I have:
<?php if (in_array("pizza", $words)) { ?>
This should show for pizza
<?php } ?>
But this isnt working, any help would be greatly appreciated!
Thanks
Aucun commentaire:
Enregistrer un commentaire