Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12304
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!yojimbo.hack!news.tokachu.com!.POSTED!not-for-mail |
|---|---|
| From | Salvatore <sal@yojimbo.hack.invalid> |
| Newsgroups | comp.lang.php |
| Subject | Re: foreach problem |
| Date | Thu, 19 Dec 2013 18:09:26 +0000 (UTC) |
| Organization | Yojimbo NNTP server |
| Lines | 24 |
| Message-ID | <l8vcom$4ro$1@news.tokachu.com> (permalink) |
| References | <4crg8sz8mnlg.kvx5ofaf71nu.dlg@40tude.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.tokachu.com "kq(Iga%czn" |
| X-Complaints-To | usenet(at)tokachu(dot)com |
| User-Agent | slrn/0.9.9p1 (FreeBSD) |
| X-Watermark | "Q(<g$Wn^DpTz4JXxaDHuCN30q%GpnrDAvbW=Ua(8qPV{5pr>IN5f~Sb{cY~~" |
| X-Reader-User | hidden; display="24EEr1QzLVIfRpxx65/wVSkg68k" |
| Xref | csiph.com comp.lang.php:12304 |
Show key headers only | View raw
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