All,
I am trying to pass each GET variable to a function and check if it was
expected.
For example, here is a sample link:
index.php?name= modname&file=fi lename&func=1
the problem is, instead of returning:
match
match
match
it returns:
match
no match
no match
no match
match
no match
no match
no match
match
I know the problem is something with the =each, because it is evaluating
each item against each other, I just don't know how to fix it.
function bmcheck ($bmc, $g)
{
$bmchk = 0;
while (list ($key, $val) = each ($bmc)) {
if ($val == $g) {
echo "match";
echo "<br>";
} else {
echo "no match";
echo "<br>";
}
}
}
$bmc = array("name","f ile","func");
foreach ($_GET as $gvalue => $g) {
bmcheck($bmc, $gvalue);
}
Basically, when I'm done, if something like this was passed:
index.php?name= modname&file=fi lename&func=1&b ad=notsupposedt obehere
then I would see 3 "matches" and 1 "no match" for the "bad" parameter.
I hope this makes some sense =)
Thanks.
I am trying to pass each GET variable to a function and check if it was
expected.
For example, here is a sample link:
index.php?name= modname&file=fi lename&func=1
the problem is, instead of returning:
match
match
match
it returns:
match
no match
no match
no match
match
no match
no match
no match
match
I know the problem is something with the =each, because it is evaluating
each item against each other, I just don't know how to fix it.
function bmcheck ($bmc, $g)
{
$bmchk = 0;
while (list ($key, $val) = each ($bmc)) {
if ($val == $g) {
echo "match";
echo "<br>";
} else {
echo "no match";
echo "<br>";
}
}
}
$bmc = array("name","f ile","func");
foreach ($_GET as $gvalue => $g) {
bmcheck($bmc, $gvalue);
}
Basically, when I'm done, if something like this was passed:
index.php?name= modname&file=fi lename&func=1&b ad=notsupposedt obehere
then I would see 3 "matches" and 1 "no match" for the "bad" parameter.
I hope this makes some sense =)
Thanks.
Comment