I have this code: <? $i=0; if (isset($_GET['x'])) { echo "x ".$i++; } if (isset($_GET['y'])) { echo "y ".$i++; } if (isset($_GET['z'])) { echo "z ".$i++; } if (isset($_GET['w'])) { echo "w ".$i++; } ?> Code (markup): Now, what I need to do is that starting from zero (the first one) I have to increase each GET (if set) with 100. Like this: if is set get 1 my $i should be 0, if is set get 2 my $i should be 100, if is set get 3 my $i should be 200, if is set get 4 my $i should be 300. How can I do that? I have tried to start with a $i=0*100; but that is not working.
$i = 0*100 is equal to zero, therefore its not working. Maybe this $i=0; if (isset($_GET['x'])) { echo "x ".$i; $i+=100; } if (isset($_GET['y'])) { echo "y ".$i; $i+=100; } if (isset($_GET['z'])) { echo "z ".$i; $i+=100; } if (isset($_GET['w'])) { echo "w ".$i; $i+=100; } PHP: or the simplified version: $getarray = array('x','y','z','w'); $i=0; foreach ($getarray as $get) { if (isset($_GET[$get])) { echo $get.' '.$i; $i+=100; } } PHP: