mkosmosports Posted November 14, 2006 Share Posted November 14, 2006 Hey Everyone,I want to create an array of a large amount of numbers (from 1 to 700), but I would like to avoid typing them all out..:) How can I create an array with a from, to or max, min number count?Thanks for you help..... Quote Link to comment Share on other sites More sharing options...
alpine Posted November 14, 2006 Share Posted November 14, 2006 [code]<?phpforeach (range(1, 700) as $number) { echo $number;}?>[/code] Quote Link to comment Share on other sites More sharing options...
printf Posted November 14, 2006 Share Posted November 14, 2006 A few ways...[code]<?php// fill an array with numbers 0 to 699 (700 elements)$my_array = range ( 0, 699 );print_r ( $my_array );// create an array with keys 0 - 699 (values set as empty )// array_fill starts at 1, so we add + 1 to start and ending values$my_array = array_slice ( array_fill ( 1, 700, '' ), 0 );print_r ( $my_array );?>[/code] 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.