Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73874 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10687 invoked from network); 4 May 2014 15:46:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2014 15:46:31 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:57056] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/70-05809-5D066635 for ; Sun, 04 May 2014 11:46:30 -0400 Received: from [192.168.2.31] (ppp-93-104-30-37.dynamic.mnet-online.de [93.104.30.37]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 6298F468A5; Sun, 4 May 2014 17:47:22 +0200 (CEST) To: Joe Watkins Cc: Aaron Lewis , internals@lists.php.net In-Reply-To: <1399216437.14925.0.camel@localhost.localdomain> References: <1399216437.14925.0.camel@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" Date: Sun, 04 May 2014 17:46:03 +0200 Message-ID: <1399218363.5851.40.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Is it possible to get the variable name from the HashTable structure? From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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