cleverlyslick Posted September 24, 2009 Share Posted September 24, 2009 what's up php freaks. This is my first post in this forum and I am a newb at PHP(just started reading and toying with php about 2 weeks ago). I've been developing static,boring websites for a year now and want to make them a little more dynamic and a friend of mine recommended me learning php.it's been a nightmare ever since lol but I am hooked on learning this program and would like to conquer it if possible. Currently, I am working on building my first dynamic website and my question is this.... I want to use numbers from 200 to 1000 and want to put it in an array. Now I know how to do arrays,but I wanted to know if it's possible to shorten up the numbers in the arrays say for example like $array = array(200-300, 301 - 600, 601-800, 801-1000)and still have each individual number function properly instead of manually having to enter each number in the array without affecting the numbers when a user types it in? say for example a user wants to type 223 and gets the result with no problems. It just seems sloppy coding for me to have to manually enter each number in the array. I hope this post makes sense and hopefully get some responses. Thanks, cleverly "not so" slick Quote Link to comment https://forums.phpfreaks.com/topic/175409-hello-everyone-my-first-post-in-this-forum/ Share on other sites More sharing options...
Alex Posted September 24, 2009 Share Posted September 24, 2009 Be more specific. Telling us exactly what you want to accomplish will allow us to tell you what the best method will be. Quote Link to comment https://forums.phpfreaks.com/topic/175409-hello-everyone-my-first-post-in-this-forum/#findComment-924343 Share on other sites More sharing options...
dad00 Posted September 24, 2009 Share Posted September 24, 2009 so you want the numbers 200-1000 in a array? dont hand type it thats the manual way use a while loop or for loop $i=199; while ($i<1000){ $i++; $array[$i]=$i; } Quote Link to comment https://forums.phpfreaks.com/topic/175409-hello-everyone-my-first-post-in-this-forum/#findComment-924346 Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2009 Share Posted September 24, 2009 It always pays to browse the documentation first for answers to basic "can php/how to do this in php" questions - http://www.php.net/manual/en/function.range.php Quote Link to comment https://forums.phpfreaks.com/topic/175409-hello-everyone-my-first-post-in-this-forum/#findComment-924349 Share on other sites More sharing options...
cleverlyslick Posted September 24, 2009 Author Share Posted September 24, 2009 so you want the numbers 200-1000 in a array? dont hand type it thats the manual way use a while loop or for loop Thanks dad00, that's exactly what I was looking for It always pays to browse the documentation first for answers to basic "can php/how to do this in php" questions - http://www.php.net/manual/en/function.range.php Thanks for the reference PF I will be sure to read through this site. appreciate the quick responses. Quote Link to comment https://forums.phpfreaks.com/topic/175409-hello-everyone-my-first-post-in-this-forum/#findComment-924371 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.