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 ... 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++; } ?> 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 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 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
Archived
This topic is now archived and is closed to further replies.