Re: Creating variable names from values

From: Date: Thu, 08 Mar 2007 18:43:06 +0000
Subject: Re: Creating variable names from values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250108@lists.php.net to get a copy of this message
Otto Wyss escreveu:
From an arry I create a table like foreach ($persons as $key => $pers) {
    echo "<td><input name=\"K$key\" type=\"checkbox\" ...></td>
          <td>...</td>
} so each checkbox field has its own name created from $key. Yet how can I access these fields (names) later on? foreach ($persons as $key => $pers) {
    if ($K???) {
      $cnt += 1; ...
    }
} Is there a better way to access multiple fields from a table? O. Wyss --------
$persons = array ( "John", "Mary", "Meany", "Jorge", "Sam", "Joseph", "Bill", "Frank" ); echo '$persons = array ( "John", "Mary", "Meany", "Jorge", "Sam", "Joseph", "Bill", "Frank" )<br /><br />list ($person01, $person02, $person03, $person04, $person05, $person06, $person07, $person08 ) = $persons'; list ($person01, $person02, $person03, $person04, $person05, $person06, $person07, $person08 ) = $persons; echo '<br /><br /><br />echo $person05<br />&nbsp;&nbsp;&nbsp;o----->&nbsp;&nbsp;&nbsp;$person05 = ' . $person05; echo '<br /><br />echo $person08<br />&nbsp;&nbsp;&nbsp;o----->&nbsp;&nbsp;&nbsp;$person08 = ' . $person08; -- zerof http://www.educar.pro.br/ Apache - PHP - MySQL - Boolean Logics - Project Management ---------------------------------------------------------- Você deve, sempre, consultar uma segunda opinião! ---------------------------------------------------------- Deixe todos saberem se esta informação foi-lhe útil. ---------------------------------------------------------- You must hear, always, one second opinion! In all cases. ---------------------------------------------------------- Let the people know if this info was useful for you! ----------------------------------------------------------

« previous php.general (#250108) next »