The second if statement in the series below keeps returning true and printing out even if estimateId
is not the only item in the array. How do I correct this?
The goal is to make sure only one if statement matches at all times in the series below.
For example, right now the second if returns true when the 3rd if does. This should not happen.
https://localhost/data.php?estimateId=1001
https://localhost/data.php?estimateId=1001&proposalsFilter=all
.
<?php
# estimates/active/
if (in_array($_GET["estimatesFilter"], $_GET)) {
print_r('estimatesFilter: ' . $_GET["estimatesFilter"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# This if keeps returning true even if estimateId is not the only item in the array?
# estimates/1001/
if (in_array($_GET["estimateId"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/proposals/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["proposalsFilter"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'proposalsFilter: ' . $_GET["proposalsFilter"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/proposals/3001/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["proposalId"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'proposalId: ' . $_GET["proposalId"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/contracts/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["contractsFilter"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'contractsFilter: ' . $_GET["contractsFilter"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/contracts/3001/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["contractId"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'contractId: ' . $_GET["contractId"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/invoices/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["invoicesFilter"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'invoicesFilter: ' . $_GET["invoicesFilter"] . ' url parameter(s) was passed.');
print_r("<br>");
}
# estimates/1001/invoices/4001/
if (in_array($_GET["estimateId"], $_GET) && in_array($_GET["invoiceId"], $_GET)) {
print_r('estimateId: ' . $_GET["estimateId"] . ' & ' . 'invoiceId: ' . $_GET["invoiceId"] . ' url parameter(s) was passed.');
print_r("<br>");
}
?>