If you want to do $_GET, consider adding multiple items in the same parameter’s input GET
.
Behold:
url?itens[]=pão&itens[]=leite&itens[]=ovo
In PHP this would return:
print_r($_GET['itens']); // ["pão", "leite", "ovo"]
In order for the url to look like the comment, you need to declare the form like this:
<input type="text" name="itens[]" value="ovo" />
<input type="text" name="itens[]" value="pão" />
To check, just save a list of expected values and compare like this:
$valores = $_GET['itens'];
ksort($valores);
$obrigatorios = ['leite', 'ovo', 'pão']
var_dump($valores === $obrigatorios);
Another way to do the check would be by using the function array_intersect
:
count(array_intersect($obrigatorios, $valores)) > 0
Are these products in a database? Mysql for example
– Miguel
It’s a simple exercise I’m trying to do, I’m putting the products in an array, and I want it when I do...php? Milk/ It says whether milk exists in the array or not
– Mario Caeiro