title: Fill HTML Form with PHP data using field's ID as identifier
body: <p>I have this array named <code>$clientinfo</code>: </p>
  
  <pre><code>[id] =&gt; 1
  [dlastname] =&gt; Brown
  [dfirstname] =&gt; George
  [dmob] =&gt; 189328937
  [dlandline] =&gt; 92839283
  </code></pre>
  
  <p>and so on... I want to populate this form:</p>
  
  <pre><code>&lt;li class="hidden"&gt;&lt;label for="did"&gt;unique id:&lt;/label&gt;&lt;input id="did" type="text" name="did" style="background-color:gray" readonly="readonly" /&gt;&lt;/li&gt;
  &lt;li class="firstcell"&gt;&lt;label for="dlastname"&gt;lastname:&lt;/label&gt;&lt;input id="dlastname" type="text" name="dlastname" /&gt;&lt;/li&gt;
  &lt;li class="middlecell"&gt;&lt;label for="dfirstname"&gt;firstname: &lt;/label&gt;&lt;input id="dfirstname" type="text" name="dfirstname"  /&gt;&lt;/li&gt; 
  &lt;li class="middlecell"&gt;&lt;label for="dmob"&gt;mob &lt;/label&gt;&lt;input id="dmob" type="text" name="dmob" /&gt;&lt;/li&gt;
  </code></pre>
  
  <p>and so on...</p>
  
  <p>I am able to fill the fields using php by adding this at the end of each input tag:</p>
  
  <pre><code>value="&lt;?php echo isset($docinfo['dlastname']) ? htmlspecialchars($docinfo['dlastname']) : ''; ?&gt;
  </code></pre>
  
  <p>This works fine, but it needs me to write something at the end of each line, which is ok if the form is small but I am working on one with at least 250 fields.</p>
  
  <p>I was wondering, since the input ID is the same as the keys of the associative array, if there is an easier, more automated way to fill this cells I had two things in mind, one to import the array to java and then do </p>
  
  <pre><code> document.INPUTID.value='$clientinfo[INPUTID]';
  </code></pre>
  
  <p>or something like that... but I cannot figure out the specifics and the second one was to somehow add a php command at each fields' code to write something like: </p>
  
  <pre><code> value="&lt;?php $id= $get_class($this); echo $clientinfo[$id]; ?&gt;"
  </code></pre>
  
  <p>I dont really know how the <code>$get_class works</code> and it screwed up my code whenever I put it in there, but maybe someone could work something out to get the specific area's id?</p>
  
  <p>I should mention i am very new at this, so you will find errors above and i will need a very detailed explanation.</p>