note 1611 modified in Variable variables by ronabop

From: Date: Sat, 10 Mar 2001 23:38:19 +0000
Subject: note 1611 modified in Variable variables by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-12242@lists.php.net to get a copy of this message
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 (#12242) next »