monkeybidz Posted November 5, 2007 Share Posted November 5, 2007 How would I get the name of a text field created by an array. The text fiel name is txt2. Array is txt0,txt1,txt2,txt3. if(isset($sessionVars['SELL_varval'])) { $varval=$sessionVars['SELL_varval']; } else $varval=array(); $TPL_auction_variant='<table width="100%">'; foreach($ltxt as $k=>$v) { $TPL_auction_variant.="<tr><td align='right' width='30%'><B><LABEL FOR=ntxt[$k]>$v:</LABEL></B></td>"; if(isset($values["txt$k"])) { $TPL_auction_variant.="<td><SELECT NAME='txt[$k]'>\n<OPTION VALUE=''>$MSG_25_0070</OPTION>\n"; foreach($values["txt$k"] as $kv=>$vv) { $TPL_auction_variant.="<OPTION VALUE='$kv' ".((stripslashes($varval["txt$k"])==$vv)?"SELECTED":"").">$vv</OPTION>\n"; } $TPL_auction_variant.="</SELECT></td>\n"; } $TPL_auction_variant.="<td width='100%'><INPUT type='text' value=\"".stripslashes($varval["txt$k"])."\" NAME='ntxt[$k]' /></td></tr>\n"; } foreach($lnum as $k=>$v) { $TPL_auction_variant.="<tr><td align='right'><LABEL FOR=ntxt[$k]>$v:</LABEL>($MSG_25_0073)</td>"; if(isset($values["num$k"])) { $TPL_auction_variant.="<td><SELECT NAME='num[$k]'>\n<OPTION VALUE=''>$MSG_25_0070</OPTION>\n"; foreach($values["num$k"] as $kv=>$vv) { $TPL_auction_variant.="<OPTION VALUE='$kv' ".(($varval["num$k"]==$kv)?"SELECTED":"").">$vv</OPTION>\n"; } $TPL_auction_variant.="</SELECT></td>\n"; } $TPL_auction_variant.="<td width='100%'><INPUT type='text' value=\"".$varval["num$k"]."\" NAME='nnum[$k]' /></td></tr>\n"; } $TPL_auction_variant.="</table>"; } else $TPL_auction_variant=''; Link to comment https://forums.phpfreaks.com/topic/76012-need-help-getting-variable-from-array/ Share on other sites More sharing options...
darkfreaks Posted November 5, 2007 Share Posted November 5, 2007 you could use extract? http://us2.php.net/manual/en/function.extract.php Link to comment https://forums.phpfreaks.com/topic/76012-need-help-getting-variable-from-array/#findComment-384735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.