m0751n Posted April 14, 2013 Share Posted April 14, 2013 hi, can you please show me a way of generating all posibillities of 10 digits from 0 to 9 with for loop for example, 0000000000 / 1000000000 / 2000000000 / etc .... thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/ Share on other sites More sharing options...
requinix Posted April 14, 2013 Share Posted April 14, 2013 First a question: what does var_dump(999999999) output for you? Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424669 Share on other sites More sharing options...
m0751n Posted April 14, 2013 Author Share Posted April 14, 2013 thanks for the answer. I'm new in php. can you please write a for loop that generates all possibilities of 10 digits Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424680 Share on other sites More sharing options...
requinix Posted April 14, 2013 Share Posted April 14, 2013 No. Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424744 Share on other sites More sharing options...
DavidAM Posted April 15, 2013 Share Posted April 15, 2013 If you want someone to write code for you, you need to post in the freelance section and be prepared to pay for it. If you have tried and are having problems, post your code and state your problems. We are here to help you figure it out, but not many people here are going to do it for you You do realize that that is 10,000,000,000 (BILLION) individual strings? I got bored, and I took a swing at this for fun. My development server is an old i386 box. For 5 digit numbers -- just to generate them into an array, no printing, no database insert, no file write -- it took 3 minutes to produce the 100,000 values and took up 13 Megabytes of memory. At 6-digits, PHP ran out of memory to hold them. So, I took the array out and started a run for 10-digits. It has been running for 4 hours now, still not done. I'm sure there is a more efficient way to write it. But it is really just one recursive function, so ... What are you going to do with the 10 BILLION names of ... uh, numbers when you get them? Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424768 Share on other sites More sharing options...
Christian F. Posted April 15, 2013 Share Posted April 15, 2013 You don't even need a recursive function, one loop is all that's needed. Still, why is an excellent question. m0751n[7b]: This is as basic loop as you can get, and you're being more than just lazy. We're here to help those who put an effort in by themselves, but get stuck for some reason. Not to do our jobs, or yours, for free. If you want people to provide you with completed code, then the Freelance section is the correct place to post it. That said, freelancers generally expect to get paid for their time and service. Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424787 Share on other sites More sharing options...
DavidAM Posted April 15, 2013 Share Posted April 15, 2013 Yeah, that's me; always doing things the hard way. I just killed that job a few minutes ago (it was at 455 minutes). Quote Link to comment https://forums.phpfreaks.com/topic/276932-for-loop-can-i-generate-all-possibilities-of-10-digits-from-0-to-9/#findComment-1424792 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.