note 24342 added to function.eval

From: Date: Tue, 13 Aug 2002 18:05:37 +0000
Subject: note 24342 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-34948@lists.php.net to get a copy of this message
Just a simple example of how to get at the values in an array using eval (maybe you can use $$ but I couldn't work out how). $fruit['a']='apples'; $fruit['b']='bananas'; $array='fruit'; $e='b'; $v='$z=$'.$array."['".$e."'];"; echo "$v -> "; eval($v); echo $z; The resulting output is: $z=$fruit['b']; -> bananas -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+24342 http://master.php.net/manage/user-notes.php?action=delete+24342 http://master.php.net/manage/user-notes.php?action=reject+24342

« previous php.notes (#34948) next »