Hi guys,
Hope you’re all doing just fine . I’d be grateful if you you can help out with this:
if ( ($country != 'Canada') || ($country != 'United States') ) {
deny all,except these two countries(either one)
exit;
}
Currently the code has to deny one or the other(whatever returns false). If am from Canada,am denied because am not from the United States(and vice versa).
I tried it with an array and xor but to no result. May be am too tired i can’t see the obvious.
<?php
echo '<dl>';
$continent = array('Canada', 'United States', 'Brazil', 'Mexico');
foreach($continent as $country):
echo '<dt><br />Country: ' .$country .'<br /></dt>';
if ( ($country === 'Canada') OR ($country === 'United States') )
{
echo '<dd>';
if ('Canada' === $country)
{
echo 'Denied because from <b>Canada</b> and not from the <b>United States</b>';
}else{
echo 'Denied because from <b>United States</b> and not from the <b>Canada</b>.';
}
echo '<br />deny either Canada OR United States';
echo '</dd>';
}
if ( ($country != 'Canada') AND ($country != 'United States') )
{
echo '<dd>';
echo 'NEITHER Canada NOR United States';
echo '</dd>';
}
endforeach;
echo '</dl>';
?>
Do the logic math.
If your word is… “Banana”
IF…TRUE OR TRUE = TRUE.
If your word is “Canada”
IF…FALSE OR TRUE = TRUE.
If your word is “United States”
IF…TRUE OR FALSE = TRUE.
You dont want OR. Assuming your test to equal 1 when the word