Re: How to do this? 6 lines of code...Parse error

xyzzy
Date: 01/03/04


Date: Sat, 3 Jan 2004 17:21:43 -0500


"Ryan A" <ryan@coinpass.com> wrote in message
news:004001c3d242$2ff18de0$0000fea9@l2zcaxu7emppqh...
> Hi,
> am a bit confused as to how you do this...first let me explain the flow of
> input:
> I will be getting $product1,$product2,$product3 etc from another
script...I
> dont know till what number....right now I am trying to catch the values
till
> 20 with a "for" loop.
>
> My problem is how do I attach the $i that I am using to the $product to
> check if its set? Heres my code and below that you will see some of the
> stuff I have tried:
>
>
> for($i=1; $i<21; $i++)
> { if(isset($product$i))
> {echo "Product".$i." is set!<br>";}
> else(!isset($product$i))
> {echo "Product".$i." is NOT set!<br>";}}
> exit;
>
>
> This is what I have tried (in the if-isset part) :
> $product.$i
> $product."".$i
> $product.''.$i
> $product($i)
>
> all of the above give me a parse error.
>
> Any help appreciated.
>
> Thanks,
> -Ryan
> P.S, I didnt write the other script where I am getting the values from...I
> just have to work with it as they are not allowing me to touch the older
> script so I dont have access to it.

Take a look at variable variables.

$myProduct = "product" . $i;
if (isset ($$myProduct)).........



Relevant Pages

  • How to do this? 6 lines of code...Parse error
    ... am a bit confused as to how you do this...first let me explain the flow of ... I didnt write the other script where I am getting the values from...I ... script so I dont have access to it. ...
    (php.general)
  • Re: [PHP] Passing vars w/refresh w/register globals off?
    ... Dont know why you want to, ... This wasy all you need is pass the ID within the browser. ... > switch for routing to desired pages according to form input data. ... I'm thinking the old script would be php3 and the new ...
    (php.general)
  • Re: Looking for maybe impossible script?
    ... The admin rights on the laptops were ... Even if i could get a script that would notify me of such ... I just dont have the time. ... aide fix and tracing them down to the port an then shuting it off. ...
    (microsoft.public.windows.server.scripting)
  • Re: Running Login Script after establishing a VPN connection
    ... I dont know what you mean by a "pure batch command". ... "Pegasus (MVP)" wrote: ... This would be equivalent to your current VB Script program ... The network drive disconnects before the bat file ...
    (microsoft.public.windows.server.scripting)
  • Re: Logs remote ip when connects to exchange, ftp, or remotly to s
    ... Thanks for your help I wont argue anymore. ... I appreciate everything now I am looking for a script to extract ... >> server through remote desktop on the desktop of his server it showed the ... I just dont know how to make this script see I am going to ...
    (microsoft.public.windows.server.scripting)