note 58519 added to faq.html

From: Date: Mon, 07 Nov 2005 08:51:28 +0000
Subject: note 58519 added to faq.html
Groups: php.notes 
Request: Send a blank email to php-notes+get-98184@lists.php.net to get a copy of this message
Sorry if this is obvious, but I needed an array of values input from a form, and I did it with variable names and PHP's '$$' feature. My form's PHP code reads like this: for ( $LINENUMBER = 1; $LINENUMBER <= $LINE_LIMIT; $LINENUMBER = $LINENUMBER + 1 ) { echo "<tr>\n"; echo "<td nowrap>$LINENUMBER</td>\n"; $SUPPLYIDENT = 'SUPPLYIDENT_' . $LINENUMBER ; $QUANTITY = 'QUANTITY_' . $LINENUMBER ; echo "<td><input\n"; echo "name='$SUPPLYIDENT'\n"; echo "type='TEXT'\n"; echo "maxlength='$IdentLength'\n"; echo "value='"; echo $$SUPPLYIDENT ; echo "'\n"; echo " /></td>\n"; echo "<td><input\n"; echo "name='$QUANTITY'\n"; echo "type='TEXT'\n"; echo "maxlength='$IdentLength'\n"; echo "value='"; echo $$QUANTITY; echo "'\n"; echo " /></td>\n"; echo "</tr>\n"; } Decoding is similar: for ( $P_LINENUMBER = 1; $P_LINENUMBER <= $LINE_LIMIT && $ErrorMessage == ""; $P_LINENUMBER = $P_LINENUMBER + 1 ) { $P_SUPPLYIDENT = 'P_SUPPLYIDENT_' . $P_LINENUMBER ; $P_QUANTITY = 'P_QUANTITY_' . $P_LINENUMBER ; if ( $$P_QUANTITY != "" ) { ... } } From the other postings, it appears that this is valid XHTML and valid HTML4 and does not reveal that your code is PHP. ---- Manual Page -- http://www.php.net/manual/en/faq.html.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58519 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58519&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58519&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98184) next »