Array element names and values

i am an 84.5 y/o male with considerable programming skills mainly c# and micro-assembly. I am teaching myself a new skill, web development, and it is a paradyme shift for me. I am unfamiliar with handling associative arrays and have var_dumped $_SERVER getting the names of elements from a var_dump and echoing their values. I feel that there must be a better way. So … how do i foreach($_SERVER … and get the element name? I get the value but i want the name. See where i’m going?

1 Like

I think what you really mean is to see the variables inside of the $_SERVER variable.

If that is the case, you can just var_dump the $_SERVER variable. E.g


Let me know if this was not what you wanted to do so I edit the answer.


Hi man,
so it is so easy.
If you have an Array with key name you can easily do array_keys method:

$keys_name = array_keys($_SERVER);

the variable $keys_name has all the keys of $_SERVER array.