Variable variables on "sections of arrays"

From: Date: Mon, 07 Aug 2000 02:56:13 +0000
Subject: Variable variables on "sections of arrays"
Groups: php.general 
Request: Send a blank email to php-general+get-10397@lists.php.net to get a copy of this message
Is there a way to have a variable variable "refer" to a vector within an array? The idea sounds alot like actual references, I realize, but moving to php4 is impractical right now. Ideally, we'd like to say something like: This snipit illustrates what we would like to do: <?php $doc = array(); $doc[0] = "goodbye"; $d = "doc[0]"; $$d = "hello"; print "$d ${$d} $doc[0]<br>\n"; var_dump($$d); print "<br>"; var_dump($doc[0]); print "<br>"; ?> The script produces: doc[0] hello goodbye string(5) "hello" string(7) "goodbye" The problem is that it makes a new variable called "doc\[0\]", and does not refer to the part of the array called $doc[0]. Is there a way, in php3, to connect them? -- --------- Paul Cifarelli pjc@pipeline.com paulc@ilx.com

« previous php.general (#10397) next »