note 5365 deleted from language.variables.variable by philip

From: Date: Mon, 17 Mar 2003 16:17:09 +0000
Subject: note 5365 deleted from language.variables.variable by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-45418@lists.php.net to get a copy of this message
This is an example of how I used form values, arrays & variables of variables. I hope it helps someone. # initialize array variable to 0 $index2=0; # This loop checks for 2 different values that repeat x times in a form # The name fields of the form are name0..name20 and content0..content20 for ($index=0; $index<21; $index++) { # Concatenate $index variable from the for loop # with the name and content strings # to create the form variables name0..name20 and content0..content20 # and ASSIGN THEIR VALUES to 2 variables. $NameFormStr=name.$index; $ContentFormStr=content.$index; # Assign field values of the form into an array $NameArray[$index2]=$NameFormStr; $ContentArray[$index2]=$ContentFormStr; # Assign array values into temporary variable to be displayed later $DisplayTmpName=$$NameArray[$index2]; $DisplayTmpContent=$$ContentArray[$index2]; # Displaying the variables as follows will render the same result 3 times # for each name-content pair. print("<br>"); print("Values to display from the Form............... Name= ${$NameFormStr} Content= ${$ContentFormStr}"); print("<br>"); printf("Values to display from Array.................... Name= %s Content= %s", $$NameArray[$index2],$$ContentArray[$index2]); print("<br>"); print("Values to display from temporary variable. Name= $DisplayTmpName Content= $DisplayTmpContent"); $index2++; } Works on NT 4, Xitami and PHP 3.0.6

« previous php.notes (#45418) next »