Echo $_GET property, NOT value?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Echo $_GET property, NOT value?

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Echo $_GET property, NOT value?

Post by Christopher »

Code: Select all

foreach ($_GET['property'] as $value) {
    echo $value;
}
(#10850)
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Echo $_GET property, NOT value?

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Echo $_GET property, NOT value?

Post by Christopher »

Code: Select all

$properties = array_keys($_GET);
foreach ($properties as $property) {
    echo $property;
}
(#10850)
Post Reply