Re: Is it possible to get the variable name from the HashTable structure?
| From: | Johannes Schlüter | Date: | Sun, 04 May 2014 15:46:03 +0000 |
| Subject: | Re: Is it possible to get the variable name from the HashTable structure? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73874@lists.php.net to get a copy of this message | ||
On Sun, 2014-05-04 at 16:13 +0100, Joe Watkins wrote:
> On Sun, 2014-05-04 at 20:21 +0800, Aaron Lewis wrote:
> > Hi,
> >
> > So PHP uses HashTable to store variables like $_POST,
> >
> > From a HashTable structure, can I get the array name?
No, a zval (which might point to a hash tale) doesn't refer to a name.
For one there in 99.99% is no need but it would cost memory(and CPU
cycles to maintain) and then there miht e multiple nae (references) or
none (temporaries etc.)
If you know the parent such hacks like
> https://gist.github.com/krakjoe/50603be7ffb1ae6e9156
might work, but even this solution is flawed: The easy thing it doesn't
support is references, it should return an array of all names. It won't
work for complex things, though.
If you need such a functionality I'd suggest to take a step back and
think what you actually want to do ... usually there is a better
solution.
johannes