I have a question A001 in which the respondent chooses an item from a drop down menu. For example, the respondent chooses 'apple' in this question.
Then I want to check if the answer is in a certain list of items:
$fruits = array('apple','pear','banana');
So I am trying to execute this via the following:
replace('%food%', 'A001', 'response');
if (in_array('%food%', $fruits, true))
$food_type ='is a fruit';
$food_type ="is NOT a fruit";
And then I want to display the outcome to the respondent like so:
html('<p>Your choice '.$food_type.' </p>');
However, when I run this code, it never finds my response 'apple' to be in the array. It always says that the response is not in the array and therefore chooses the option "is NOT a fruit"
Am I doing something wrong here?
I appreciate any advice!