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..... Link to comment https://forums.phpfreaks.com/topic/27214-arrays-from-to/ 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] Link to comment https://forums.phpfreaks.com/topic/27214-arrays-from-to/#findComment-124420 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] Link to comment https://forums.phpfreaks.com/topic/27214-arrays-from-to/#findComment-124427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.