I'm a PHP learner and I'm trying to get a string part from URL and echo it but only if that string contains in my array.
For example,
my dynamic URL looks like this.
test.com/?email=xyz@[email protected]
my array looks like this.
[email protected], [email protected], ...
What I want to do is echo the email only when the value is in my array. Since [email protected] is in the array, this will be echoed. But something like [email protected]will not be echoed because it is not in the array.
I tried the following but it's not working because I'm having trouble combining these two logic.
$array = array('[email protected]', '[email protected]', '[email protected]', '[email protected]');
if (isset($_GET['email'])) AND (in_array('email', $array)) {
echo $_GET['email'];
}
which gives an error on ...
... PHP 8.0.0 - 8.0.8:
Parse error: syntax error, unexpected token "and"
... PHP 7.3.0 - 7.3.29, 7.4.0 - 7.4.21:
Parse error: syntax error, unexpected 'AND' (T_LOGICAL_AND)
in_array($_GET['email'], $array)if (in_array($_GET['email'], $array));