I've done a few searches and not come up with anything, I'm sure it's obvious.
Basically I'm trying to work out if anything has been passed via GET from a form.
I know how to check for individual elements, but I just want to do a quick check if anything at all is passed
Cheers
Be careful when using count($_GET)
. If you submit the form with empty values it will still create keys for the fields, and your count()
will be greater than 0 and empty($_GET)
will be false.
<?php
print_r($_GET);
?>
<form action="" method="get">
<input type="text" name="name">
<textarea name="mytext"></textarea>
<input type="submit">
</form>
Make sure the fields are actually not empty:
function ne($v) {
return $v != '';
}
echo count($_GET); // prints 2
echo count(array_filter($_GET, 'ne')); // prints 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With