title: How to fetch multiple row value which contains multiple value separated by comma into a single array in php using pdo mysql
body: <p>I have a database table name books. Now I need to fetch value from multiple row values (column name position) which contains multiple value separated by comma. Now I need to fetch values from multiple rows into an array using pdo php.</p>
  <p><a href="https://i.stack.imgur.com/Z2R7z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z2R7z.png" alt="enter image description here" /></a></p>
  <pre><code>&lt;?php
  require_once &quot;includes\config.php&quot;;
  
  $sql = 'SELECT * FROM books WHERE shelf_no=2';
  $stmt = $db-&gt;prepare($sql);
  $stmt-&gt;execute();
  $row = $stmt-&gt;fetchALl(PDO::FETCH_ASSOC);
  $d = array();
  foreach ($row as $value) {
  $d[] = explode(&quot;,&quot;,$value['position']);
  }
  
  print_r($d);
  ?&gt;
  </code></pre>
  <p>and the result is</p>
  <pre><code>Array (
    [0] =&gt; Array (
      [0] =&gt; b1 
      [1] =&gt; b2 
    ) 
    [1] =&gt; Array ( 
      [0] =&gt; a2 
      [1] =&gt; a3
    )
  )
  </code></pre>
  <p>But I need all values in a single array, like this:</p>
  <pre><code>Array ( [0] =&gt; b1 [1] =&gt; b2 [2] =&gt; a2 [3] =&gt; a3 )
  </code></pre>