title: php foreach loop, not able to assign values to proper variable names?
body: <p>I need some help with the foreach loop.  Say I have this method:</p>
  
  <pre><code>public function showPaymentDetails() {
  
      $data = array("name"             =&gt; $this-&gt;name,
                    "lastname"         =&gt; $this-&gt;lastname,
                    "email"            =&gt; $this-&gt;email, 
                    "company"          =&gt; $this-&gt;company,
                    "event_name"       =&gt; $this-&gt;event_name,
                    "event_price"      =&gt; $this-&gt;event_price,
                    "uniqid"           =&gt; $this-&gt;uniqid,
                    "mobile"           =&gt; $this-&gt;mobile,
                    "travel"           =&gt; $this-&gt;travel,
                    "job"              =&gt; $this-&gt;job,
                    "how_hear"         =&gt; $this-&gt;how_hear,
                    "geusts"           =&gt; $this-&gt;guests,
                    "slider_network"   =&gt; $this-&gt;slider_network,
                    "slider_invest"    =&gt; $this-&gt;slider_invest,
                    "slider_investors" =&gt; $this-&gt;slider_investors,
                    "gender"           =&gt; $this-&gt;gender
                    );
  
      return $data;
  
  }
  </code></pre>
  
  <p>Now i want to assign each value of an array to a variable. This is what I do:</p>
  
  <pre><code>$i = 0;
  foreach($data as $row[$i]) {
      $row[$i];
      $i++;
  }
  
  echo $row[0];
  echo $row[1];
  echo $row[2];
  </code></pre>
  
  <p>As you can see I am assigning values to <code>$row[]</code>. Which is really bad. How can I assign those values to such variable names as <code>$name</code>, <code>$lastname</code> etc.</p>
  
  <p>Thanks!</p>