anabelle Posted October 28, 2006 Share Posted October 28, 2006 Hi, im using a really simple script in www.gathacol.net/cenefa/ver.php?id=001 to generate the links in the arrows, im using [code]<? echo($id+1) ?>[/code]but it generates a single digit variable.. and i need always 3 digit so that the id works.How can i do to make the links to a three digit id? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 28, 2006 Share Posted October 28, 2006 Use [url=http://www.php.net/sprintf]sprintf()[/url][code]<?phpecho sprintf("%03d",$id);?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 28, 2006 Share Posted October 28, 2006 Assuming you want leading 0's:[code]$linkID = "00".($id+1);$linkID = substr($linkID,strlen($linkID)-3,3)echo $linkID;[/code]EDIT: Nevermind, I like his solution better. Quote Link to comment Share on other sites More sharing options...
anabelle Posted October 28, 2006 Author Share Posted October 28, 2006 thanks ;) im using sprintfit works great! 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.