note 35378 deleted from language.variables.variable by nlopess

From: Date: Sat, 22 May 2004 08:17:38 +0000
Subject: note 35378 deleted from language.variables.variable by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69939@lists.php.net to get a copy of this message
Note Submitter: Stoker overatthe sauen d com ---- Using variable variables with arrays, I've been searching quite a bit for it and have not found any solutions, and the comments here indicate the same as what i found, that $myarray = array ('Sierra Nevada','Sam Adams'); $arraypath = 'myarray[0]'; echo ${$arraypath}; does not work (at least not in PHP 4.3.2). A "dirty" workaround is to use eval, but be careful and do not use submitted data in the eval statement directly (Security).. Instead of the echo above you could do something like eval ('$myval = $'.$arraypath.';'); echo $myval; (Could also do echo in the eval, depending on what you need the value for)

« previous php.notes (#69939) next »