Jump to content

Writing a simple statement with an index


makamo66

Recommended Posts

I can write this and get the right results:

 

if ( $_SESSION['addId'] == 'add[4]' )

$productId = 1;

if ( $_SESSION['addId'] == 'add[5]' )

$productId = 2;

if ( $_SESSION['addId'] == 'add[6]' )

$productId = 3;

 

But if I try to streamline it by writing it this way, it doesn't work:

 

if ( $_SESSION['addId'] == 'add[$i]' )

$productId = $i;

 

I think the two methods should be equivalent so why doesn't the second way work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.