Re: http://bugs.php.net/bugs.php?id=8409
| From: | Stig Venaas | Date: | Mon, 08 Jan 2001 19:02:51 +0000 |
| Subject: | Re: http://bugs.php.net/bugs.php?id=8409 | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-43433@lists.php.net to get a copy of this message | ||
On Mon, Jan 08, 2001 at 12:42:15PM -0600, Andrei Zmievski wrote:
> On Mon, 08 Jan 2001, Stig Venaas wrote:
> > This sounds like a good idea, should be backwards compatible. Except
> > that I think the result should be
> >
> > creates $prefix0, $prefix1, and $prefix2 in your case. After all the
> > indices are 0, 1 and 2, and adding _ doesn't seem natural. You can
> > call your prefix prefix_ then.
>
> In retrospect, I shouldn't have had extract() append _ automatically. If
> you change it now, you will break all the scripts that use prefix
> option, though.
Ah okay, I see, I should have read the doc, never used extract and
wasn't aware of that, sorry. I suggest then that if some elements
of an array has numeric indices we simply treat them as strings, so
for example:
array("a" => "b", 6 => "c") gives the variables prefix_a and
prefix_6,
or put another way, we treat the indices as strings. Seems like this
only makes sense with EXTR_PREFIX_ALL.
> No, it won't. If you don't use the prefix option, some of the key values
> may not constitute valid variable names and won't be extracted.
Right. I guess there could have been an option EXTR_PREFIX_NECESSARY or
something that only prefixes when necessary to create a legal variable
name, in particular numbers, but that's getting complicated.
Returning the number of variables sounds like a good idea then.
If you agree this is good I could always try to implement it unless
cynic or you wants to.
Stig