TheFilmGod Posted February 20, 2007 Share Posted February 20, 2007 <?php $num="2"; ?> .... image/<?php echo --$num; ?> .... image/<?php echo ++$num; ?> Why does the first one end up as 1, and the second image/... ends up as 2. Please tell me how I can reset the variable so that the ++ does not influence the updated variable but the original one. Link to comment https://forums.phpfreaks.com/topic/39265-solved-php-increment-and-decrement/ Share on other sites More sharing options...
JBS103 Posted February 20, 2007 Share Posted February 20, 2007 You can either restate $num = 2 or you can change $num++; to $num + 2. As far as I know, there aren't many other ways around it. You can use two different variables. Link to comment https://forums.phpfreaks.com/topic/39265-solved-php-increment-and-decrement/#findComment-189203 Share on other sites More sharing options...
TheFilmGod Posted February 20, 2007 Author Share Posted February 20, 2007 Hey! It worked! Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/39265-solved-php-increment-and-decrement/#findComment-189205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.