Variable variables into an array.

[email protected] (Richard Quadling)
Newsgroups php.general
Message-ID <[email protected]>
Hi.

Quick set of eyes needed to see what I've done wrong...

The following is a reduced example ...

<?php
$Set = array();
$Entry = 'Set[1]';
$Value = 'Assigned';
$$Entry = $Value;
print_r($Set);
?>

The output is an empty array.

Examining $GLOBALS, I end up with an entries ...

    [Set] => Array
        (
        )

    [Entry] => Set[1]
    [Value] => Assigned
    [Set[1]] => Assigned


According to http://docs.php.net/manual/en/language.variables.basics.php,
a variable named Set[1] is not a valid variable name. The [ and ] are
not part of the set of valid characters.

In testing all the working V4 and V5 releases I have, the output is
always an empty array, so it looks like it is me, but the invalid
variable name is an issue I think.

Regards,

Richard.

NOTE: The above is a simple test. I'm trying to map in nested data to
over 10 levels.
-- 
Richard Quadling.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.