swiss73 Posted November 24, 2006 Share Posted November 24, 2006 Hi. I want to echo a random number 01 to 29. I can't rename the files as left-1.jpg to left-29.jpg. they have to stay as left-01.jpg to left-29.jpgwho can help with this? I searched but did not find how to format numbers in php Quote Link to comment Share on other sites More sharing options...
taith Posted November 24, 2006 Share Posted November 24, 2006 [code]$i = rand(1,29);if(strlen($i)==1) $i = '0'.$i;[/code] Quote Link to comment Share on other sites More sharing options...
swiss73 Posted November 24, 2006 Author Share Posted November 24, 2006 thank you. that is an intelligent answer indeed. :) Quote Link to comment Share on other sites More sharing options...
taith Posted November 24, 2006 Share Posted November 24, 2006 your quite welcome :-D Quote Link to comment Share on other sites More sharing options...
mansuang Posted November 24, 2006 Share Posted November 24, 2006 [code=php:0]$i = sprintf("%02d",rand(1,29));[/code]here is another choice. Quote Link to comment Share on other sites More sharing options...
swiss73 Posted November 24, 2006 Author Share Posted November 24, 2006 [quote author=mansuang link=topic=116171.msg473170#msg473170 date=1164390648][code=php:0]$i = sprintf("%02d",rand(1,29));[/code]here is another choice.[/quote]thank you very much I will try that too. Quote Link to comment 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.