Twister1004 Posted October 28, 2011 Share Posted October 28, 2011 Hello everyone, I have been trying several things,recently, and I can't figure out how to get a series of numbers, grouped together as a string of number, instead of it adding or grabbing the last number that was randomly generated. I'm wanting to save it in a variable (of course), so I can pass it though a query when it is needed. foreach($array as $number){ echo $number; } $array is the variable where it is an array but all the randomly generated numbers are stored there. All / any help would be gratefully appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/249993-an-easy-way-to-extract-array-data/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2011 Share Posted October 28, 2011 If you post an example of what you are trying to produce, I'm sure someone can help you. Your post above doesn't exactly show what you have and what you are trying to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/249993-an-easy-way-to-extract-array-data/#findComment-1283040 Share on other sites More sharing options...
ManiacDan Posted October 28, 2011 Share Posted October 28, 2011 Yeah...sorry, I can't tell what you want here. Maybe you could research the implode function. Quote Link to comment https://forums.phpfreaks.com/topic/249993-an-easy-way-to-extract-array-data/#findComment-1283046 Share on other sites More sharing options...
Twister1004 Posted October 28, 2011 Author Share Posted October 28, 2011 Ok, my random number go between 1-20, and it loops 5 times. So my array would look like $array = array(); for($i = 0; $i<5; $i++){ $array[$i] = rand(0,20); } So my array has the all the random numbers in there. But what I'm trying to do as my goal: is to put all the numbers as a STRING. So it looks like: 1510253, instead of it being added together, and put them in a variable so that was I don't have to do a foreach statement in my query (which is bad in my opinion). The implode Function does work. I've never used it until now... Thank you very much Maniac! Quote Link to comment https://forums.phpfreaks.com/topic/249993-an-easy-way-to-extract-array-data/#findComment-1283054 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.