Re: How to construct variable names ?!

From: Date: Sun, 26 Nov 2000 10:50:58 +0000
Subject: Re: How to construct variable names ?!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-27254@lists.php.net to get a copy of this message
At 10:54 +0100 26-11-00, Juergen Hall wrote: >> >I have a string array like >> >$fuse >> >and get its values by >> >$fuse[0], $fuse[1], ... and so on >> > >> >how do i generate corresponding >> >variables like >> >$fuse1, $fuse2, ...and so on >> >> I use >> eval("\$fuse$i=$something;"); >> where $i is the counter. >> > >cool, thanks. >i didn't consider eval. >The backslash is for preventing the parser >from translating "$fuse$i" and $something >into nonsense, i assume. Yes, if prevents the variable from beeing preamturely evaluated. I use this tecnique when I hade to post arrays trough froms. And remember - you debug the eval-expressions by running the parameters through echo - if you get a bug in eval("\$fuse$i=$something;"); , you van debug it by doing echo("\$fuse$i=$something;"); -- Morten Dreier http://www.pobox.com/~mdreier/

« previous php.general (#27254) next »