title: PHP get the strings separate to store in the array
body: <p>I am working on my PHP to fetch the data from the mysql database. I have got a problem with storing the filename in the array using the values when I have stored both filenames in a database.</p>
  
  <p>Here is what I have stored in the blob:</p>
  
  <pre><code>draft_attachment.rar
  draft_attachment - Copy.rar
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>$mailbox = $link-&gt;prepare("SELECT * FROM draft WHERE id = ?");
  $mailbox-&gt;execute([$id]);
  
  // set the resulting array to associative
  $row = $mailbox-&gt;fetch(PDO::FETCH_ASSOC);
  $attachments = array();
  
  if($mailbox-&gt;rowCount() == 1)
  {
      $attachment = array();
      $draft_to = htmlspecialchars($row['to_email']);
      $draft_subject = quoted_printable_decode($row['subject']);
      $draft_message = $row['message'];
      $attach[] = $row['attachments'];
  }
  ?&gt;
  </code></pre>
  
  <p>When I try this:</p>
  
  <pre><code>$attach[] = $row['attachments'];
  </code></pre>
  
  <p>It will store both strings in the array:</p>
  
  <pre><code>Array
  {
     [0] =&gt; draft_attachment.rar
  draft_attachment - Copy.rar
  }
  </code></pre>
  
  <p>So I have tried this:</p>
  
  <pre><code>$attachments = array();  
  $i = 0;
  
  if($mailbox-&gt;rowCount() == 1) {
      $attachments[$i] = $row['attachments'];
      $i++;
  }
  </code></pre>
  
  <p>It wont store the strings separate so I dont know what to do.</p>
  
  <p>Here is what I want to achieve:</p>
  
  <pre><code>Array
  {
     [0] =&gt; draft_attachment.rar
     [1] =&gt; draft_attachment - Copy.rar
  }
  </code></pre>
  
  <p>Can you please show me an example how I could get both strings to go separate so I could be able to store them in the array using the value?</p>
  
  <p>Thank you.</p>