note 39270 modified in language.variables.external by philip

From: Date: Thu, 12 Feb 2004 21:57:01 +0000
Subject: note 39270 modified in language.variables.external by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65068@lists.php.net to get a copy of this message
How to pass a numerically indexed array. This is the part inside the form. Notice that the name is not 'english[$r]' which you would normally write, but 'english[]'. PHP adds the index when it receives the post and it starts at 0. <?php for ($r=0; $r <= count($english)-1; $r++){ echo "<TEXTAREA NAME='english[]'>".$english[$r]."</TEXTAREA>"; } ?> <?php And this will get it out at the other end function retrieve_english(){ for ($r=0; $r <= count($_POST['english'])-1; $r++){ echo $_POST['english'][$r]."<BR>"; } } ?> Keys are useful but so are numerical indices! Cheers everyone --was-- How to pass a numerically indexed array. This is the part inside the form. Notice that the name is not 'english[$r]' which you would normally write, but 'english[]'. PHP adds the index when it receives the post and it starts at 0. <?php for ($r=0; $r <= count($english)-1; $r++){ echo "<TEXTAREA NAME='english[]',>".$english[$r]."</TEXTAREA> } ?> <?php And this will get it out at the other end function retrieve_english(){ for ($r=0; $r <= count($_POST['english'])-1; $r++){ echo $_POST['english'][$r]."<BR>"; } } ?> Keys are useful but so are numerical indices! Cheers everyone http://www.php.net/manual/en/language.variables.external.php

« previous php.notes (#65068) next »