Re: filling an array

From: Date: Fri, 26 Jul 2002 20:10:31 +0000
Subject: Re: filling an array
Groups: php.general 
Request: Send a blank email to php-general+get-109873@lists.php.net to get a copy of this message
for($i =0; $i < 5; $i++) { $offset = $m + 1; $divid[$m] = $div_id{$offset}; } That should work. You'll most often want to start your arrays with zero, since it is the first pointer position, by default. The offset is so that your initial variables to be stored into the array stay numbered starting at one. If you are doing this from a form with five textboxes though, just put the name of each textbox as "div_id[]" and it will build the array for you. Hope to help! Martin Clifford Homepage: http://www.completesource.net Developer's Forums: http://www.completesource.net/forums/ >>> Steve Buehler <steve@vespro.com> 07/26/02 03:48PM >>> Can anyone tell me what I am doing wrong? I am essentially trying to do this: $divid[1] = $div_id1; $divid[2] = $div_id2; $divid[3] = $div_id3; $divid[4] = $div_id4; $divid[5] = $div_id5; But I was looking for a tighter way, like the following (which does not work): for($m=1;$m<=5;$m++){ $div_id[$m]=$divid$m; } Can anybody tell me how to do this in a "for" statement? Thanks In Advance Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#109873) next »