0
Colleagues,
we have a menu with 11 items and each item will open a page containing their respective PDF files. To avoid creating 11 different pages, we just create a page called pdf.php and put it in the links in this menu as follows:
<a href='?pag=1'>Orçamentário</a>
<a href='?pag=2'>Dados</a>
<a href='?pag=3'>Contas</a>
Up to link number 11 and we are rescuing within the same page that contains the menu in this way:
<?php if(isset($_REQUEST['pag'])){ include("pdf.php?pag=".$_REQUEST['pag']);} ?>
However, this will generate a querystring in the browser. Ex.: www.site.com.br? pag=1. So to prevent the user from typing the numbering directly into the wrong browser. Ex.: www.site.com.br? pag=12, we would like a message to appear to him Select an item from the menu.
To avoid giving an if() or switch() 11 times, we thought of creating an array with fixed values from 0 to 11 and if these values did not exist, the message would appear.
How could we do that? We thought about using in_array, but we couldn’t. See:
$array = array("0","1","2","3");
if(in_array(array(), $array)){
echo "ok";
}else{
echo "ops";
}
I think the question is dup
– MarceloBoni
Besides being asked by Voce is passing the first wrong parameter the first is the value that Voce wants to find, not an empty array as used.
– Neuber Oliveira