I am trying to create a script that checks if a certain value is in a comma delimited string, and if the value is present, it should return true else it should return false.
Basically, I am trying to check if a user has voted for a specific person before, and if so, they cannot vote again, if they have not, vote and then add their uid to the database.
I am using explode to get all the values into an array, but I am unsure about the checking function, I have a few ideas but this is quite an important script so I wanted to see if there is a better way of going about it.
$test = "john,jack,tom";
$exploded = explode(",",$test);
$hostID = "john";
foreach($exploded as $one){
if($one == $hostID){
$return = TRUE;
}else{
$return = FALSE;
};
};
Thanx in advance!
trueandfalse.}is not needed$return = TRUEdoes not actually stop the function. Maybe you doreturn $return.Code: