Brickley Posted March 11, 2009 Share Posted March 11, 2009 Hello everyone, Try as I might, "range" is not producing the kind of result I was expecting - I'm looking for a range of numbers (in this case 0 - 99) separated by commas and maybe a space (it that's not asking too much. foreach (range(0, 99) as $zipCount) {// Buid array of 100 numbered elements echo $zipCount; } ...produces this result - one long number rather than 100 numbers with commas and spaces 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 I've tried it on safari, ff and ie7 with the same results. Any thoughts? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/148891-home-on-the-range/ Share on other sites More sharing options...
kenrbnsn Posted March 11, 2009 Share Posted March 11, 2009 Use explode with range <?php echo explode(', ',range(0,99)); ?> or <?php echo explode(' ',range(0,99)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/148891-home-on-the-range/#findComment-781820 Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 Ehmm... Implode.... <?php echo implode(', ',range(0,99)); ?> Link to comment https://forums.phpfreaks.com/topic/148891-home-on-the-range/#findComment-781863 Share on other sites More sharing options...
kenrbnsn Posted March 11, 2009 Share Posted March 11, 2009 Yes, implode, not "explode". Sorry -- I was posting when I should have been sleeping... Ken Link to comment https://forums.phpfreaks.com/topic/148891-home-on-the-range/#findComment-781934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.