title: How to extract qr code contents and store it as an array in php?
body: <p>I have this qr code content that I've extracted using QR scanner web application. Example below only.</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>// This is the string extracted from the QR Code
  "Name1","Name2","Name3","Name4","Name5","Name6","Name7"
  </code></pre>
  
  <p>And I've assigned it to a variable when I submit it to store into my database </p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
    if(isset($_POST['submit'])) {
      $qr_results = $_POST['qr_bookingresults'];
      $array_results = ltrim($qr_results,"QR Code:"); // I used ltrim because there is a string QR Code: attached when I extract the qr code
  
      echo $array_results;
  
    }
  
  
  ?&gt;
  </code></pre>
  
  <p>But when I use <code>print_r function()</code> the string only stores in one array like this:</p>
  
  <pre><code>$fetchresult = array($array_results); // Assign variable and convert $array_results variable to an array
  print_r($fetchresult);
  </code></pre>
  
  <p><strong>print_r() function Result</strong></p>
  
  <pre><code>Array ( [0] =&gt; "Name1","Name2","Name3","Name4","Name5","Name6","Name7" )
  </code></pre>
  
  <p>My question is, why is it only stores the whole string into one array? wherein it should be like this.</p>
  
  <pre><code>Array ( [0] =&gt; Name1 [1] =&gt; Name2 [2] =&gt; Name3 [3] =&gt; Name4 [4] =&gt; Name5 [5] =&gt; Name6 [6] =&gt; Name7 )
  </code></pre>
  
  <p>Because what I really want to do is extract the contents and store it into an array so that I can have the freedom to insert it into mysql like this:</p>
  
  <pre><code>// Assign each variable to an array for inserting into mysql
  $name1 = $fetchresult[0];
  $name2 = $fetchresult[1];
  $name3 = $fetchresult[2];
  $name4 = $fetchresult[3];
  $name5 = $fetchresult[4];
  $name6 = $fetchresult[5];
  $name7 = $fetchresult[6];
  </code></pre>
  
  <p>Does anyone know how to fix this problem? Thanks</p>