Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12304
| From | Salvatore <sal@yojimbo.hack.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: foreach problem |
| Date | 2013-12-19 18:09 +0000 |
| Organization | Yojimbo NNTP server |
| Message-ID | <l8vcom$4ro$1@news.tokachu.com> (permalink) |
| References | <4crg8sz8mnlg.kvx5ofaf71nu.dlg@40tude.net> |
On 2013-12-19, richard <noreply@example.com> wrote:
><?php
>
> $alist="$art".$year;
> $num=0;
> foreach ($alist as $num){ echo $list[$num++][0]; }
> ?>
I think you should consider changing the way you write arrays. Instead
of using "$art60[][]", you could use "$art[60][][]". It also appears
that you mistyped the variable name in the "foreach" loop -- did you
mean to type "$alist[$num++][0]"? And why are you incrementing the
"$num" variable?
Nevertheless, there *is* a way to do this:
$varname = '$art' . $year; // Note the single quotes.
$alist = eval("return $varname;");
I don't recommend this, though. It's a security issue.
--
Blah blah bleh...
GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
foreach problem richard <noreply@example.com> - 2013-12-19 12:42 -0500
Re: foreach problem Tim Streater <timstreater@greenbee.net> - 2013-12-19 18:06 +0000
Re: foreach problem Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-19 19:13 +0000
Re: foreach problem The Natural Philosopher <tnp@invalid.invalid> - 2013-12-19 19:19 +0000
Re: foreach problem The Natural Philosopher <tnp@invalid.invalid> - 2013-12-19 19:19 +0000
Re: foreach problem Salvatore <sal@yojimbo.hack.invalid> - 2013-12-19 18:09 +0000
Re: foreach problem Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-19 19:55 +0100
csiph-web