Lodius2000 Posted June 30, 2008 Share Posted June 30, 2008 I cant get this to auto-increment dunno what I am doing wrong <?php $number = 01; $file = date('m').date('j').date('y').'_'.($number++).'sm.jpg'; while($number < 100){ print $file; print "<br />\n"; } ?> i want it to print 062908_01sm.jpg 062908_02sm.jpg ... Quote Link to comment https://forums.phpfreaks.com/topic/112522-solved-easy-onewhat-am-i-doing-wrong-auto-incrementing/ Share on other sites More sharing options...
LooieENG Posted June 30, 2008 Share Posted June 30, 2008 <?php $number = 01; $file = date('m').date('j').date('y').'_'.($number).'sm.jpg'; while($number < 100){ print $file; print "<br />\n"; $number++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/112522-solved-easy-onewhat-am-i-doing-wrong-auto-incrementing/#findComment-577752 Share on other sites More sharing options...
kenrbnsn Posted June 30, 2008 Share Posted June 30, 2008 Try: <?php $today = date('mjy'); for ($i = 1; $i<100;$i++) { $file = $today . '_' . sprintf("%02d",$i) . 'sm.jpg'; echo $file . "<br />\n"; } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/112522-solved-easy-onewhat-am-i-doing-wrong-auto-incrementing/#findComment-577754 Share on other sites More sharing options...
Lodius2000 Posted June 30, 2008 Author Share Posted June 30, 2008 perfect ken thanks Quote Link to comment https://forums.phpfreaks.com/topic/112522-solved-easy-onewhat-am-i-doing-wrong-auto-incrementing/#findComment-577756 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.