I have the following FOREACH comparing a session variable to a database string delimited with ",". Assuming that string is "1,2" and $_SESSION['id']="1", it should break the loop and forget the ELSE - shouldn't it??
foreach (explode(",",$row2['review_subscribers']) as $subscriber) {
if ($subscriber==$_SESSION['id']) {
echo '<input type="checkbox" name="subscription" value="unsubscribe" /> Unsubscribe from this topic';
break;
} else {
echo '<input type="checkbox" name="subscription" value="subscribe" /> Subscribe to this topic';
}
}
For some reason when the condition in the IF statement is met, it style echoes the ELSE and doesn't break out of the FOREACH.
Any ideas?
Thanks in advance.