SuperBlue Posted September 21, 2010 Share Posted September 21, 2010 I have a switch, which i use to alternate between two numbers. But for some reason, a duplicate occurs exactly at the count of 4, and i haven't been able to figure out why. $Count = 1; switch ($Count) { case 1: ++$Count; break; case 2: --$Count; break; } Should output: 2 1 2 1 2 ... But for some reason it gives the below instead.. 2 1 2 1 1 2 1 ... Subsequent output after the error appears completely normal. Link to comment https://forums.phpfreaks.com/topic/213984-switch-duplicates-exactly-at-4/ Share on other sites More sharing options...
rwwd Posted September 21, 2010 Share Posted September 21, 2010 Stupid suggestion I Deleted my comment.. Link to comment https://forums.phpfreaks.com/topic/213984-switch-duplicates-exactly-at-4/#findComment-1113616 Share on other sites More sharing options...
SuperBlue Posted September 21, 2010 Author Share Posted September 21, 2010 I was just a bit to quick when writing the source. The switch was placed the wrong place, so it allowed inclusion of inactive posts, before it calculated the current count. I nearly thought that either PHP, or I got the math wrong.. Link to comment https://forums.phpfreaks.com/topic/213984-switch-duplicates-exactly-at-4/#findComment-1113619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.