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 created only one page called pdf.php and put it in the links of 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 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 entering the numbering directly in the wrong browser. Eg: www.site.com.br?pag=12, we would like a message to appear for it Select a menu item .
To avoid giving an if () or switch () 11 times, we thought of creating an array with fixed values from 0 to 11 and if there were no such values, the message would appear.
How could we do this? We thought about using in_array, but we could not. See:
$array = array("0","1","2","3");
if(in_array(array(), $array)){
echo "ok";
}else{
echo "ops";
}