Page 1 of 1

Echo $_GET property, NOT value?

Posted: Wed Feb 27, 2008 12:03 pm
by JAB Creations
example.php?property=value

I only want to echo the $_GET property, not the value but when I do echo $_GET PHP echos an array (which I can understand) but I'd like it to just echo property in this instance, how do I achieve that?

Re: Echo $_GET property, NOT value?

Posted: Wed Feb 27, 2008 12:04 pm
by Christopher

Code: Select all

foreach ($_GET['property'] as $value) {
    echo $value;
}

Re: Echo $_GET property, NOT value?

Posted: Wed Feb 27, 2008 12:11 pm
by JAB Creations
Err thanks but I think I should have clarified that I'm using the term 'property' only to reference the first part of a set in the query so 'property' could be anything (fruit, magazine, animal, etc).

example.php?animal should echo animal

example.php?ocean should echo ocean

example.php?property should echo property

Re: Echo $_GET property, NOT value?

Posted: Wed Feb 27, 2008 12:45 pm
by Christopher

Code: Select all

$properties = array_keys($_GET);
foreach ($properties as $property) {
    echo $property;
}