sKunKbad Posted November 17, 2007 Share Posted November 17, 2007 Why does this echo infinite 3s instead of 123: <?php $count = 3; for ($i = 1; $i = $count; $i++) { echo $i; } ?> I just want 123. Link to comment https://forums.phpfreaks.com/topic/77694-solved-infinite-loop/ Share on other sites More sharing options...
tibberous Posted November 17, 2007 Share Posted November 17, 2007 Umm... because you are setting i to count. for ($i = 1; $i < 4; $i++) echo $i; 123 Link to comment https://forums.phpfreaks.com/topic/77694-solved-infinite-loop/#findComment-393306 Share on other sites More sharing options...
axiom82 Posted November 17, 2007 Share Posted November 17, 2007 <?php $count = 3; for ($i = 1; $i <= $count; $i++){ echo $i; } ?> Link to comment https://forums.phpfreaks.com/topic/77694-solved-infinite-loop/#findComment-393307 Share on other sites More sharing options...
sKunKbad Posted November 17, 2007 Author Share Posted November 17, 2007 OK, I see, thanks axiom82 Link to comment https://forums.phpfreaks.com/topic/77694-solved-infinite-loop/#findComment-393308 Share on other sites More sharing options...
phpQuestioner Posted November 17, 2007 Share Posted November 17, 2007 <?php $count = 3; for ($i = 1; $i <= $count; $i++) { echo "$i"; } ?> Link to comment https://forums.phpfreaks.com/topic/77694-solved-infinite-loop/#findComment-393309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.