note 1611 modified in Variable variables by jeroen

From: Date: Thu, 24 May 2001 00:11:45 +0000
Subject: note 1611 modified in Variable variables by jeroen
Groups: php.notes 
Request: Send a blank email to php-notes+get-14230@lists.php.net to get a copy of this message
[Ed: You're now using the (indeed yet undocumented) ${expression} syntax] Creating variable variables on the fly.. I had a problem I needed to get "n" variables named "x_1, x_2 .... x_n". To do this when n is passed as a parameter I used a little (undocumented?) trick. for($i=0;$i<$n;$i++){ $finalvar=${"x_$i"}; /* this is the trick! */ } http://www.php.net/manual/variable-variables.php

« previous php.notes (#14230) next »