FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » foreach problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: foreach problem [message #184267 is a reply to message #184265] Thu, 19 December 2013 18:09 Go to previous messageGo to previous message
Salvatore is currently offline  Salvatore
Messages: 38
Registered: September 2012
Karma:
Member
On 2013-12-19, richard <noreply(at)example(dot)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++
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: URL linking to 3d array
Next Topic: working model of the latest project
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 10:14:34 GMT 2024

Total time taken to generate the page: 0.05590 seconds