title: Combine multiple array but when one array is empty not show anything in php
body: <p>I need help about combine multiple array from database and fetch with </p>
  
  <pre><code>fetchAll(PDO::FETCH_ASSOC)
  </code></pre>
  
  <p>first I look for data member with percentage of 90% and every data in search in database in subtract one column in query "SELECT", for example like this :</p>
  
  <pre><code>$query1 = "SELECT * FROM tb_member WHERE category = '1' AND gender = 'M' AND age = '30'";
  $stmt1 = $this-&gt;db-&gt;prepare($query1);
  $stmt1-&gt;execute();
  $data1 = $stmt1-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  $query2 = "SELECT * FROM tb_member WHERE category = '1' AND age = '30'";
  $stmt2 = $this-&gt;db-&gt;prepare($query2);
  $stmt2-&gt;execute();
  $data2 = $stmt2-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  $query3 = "SELECT * FROM tb_member WHERE category = '1' AND gender = 'M'";
  $stmt3 = $this-&gt;db-&gt;prepare($query3);
  $stmt3-&gt;execute();
  $data3 = $stmt3-&gt;fetchAll(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p>And I combine the array with a sample code like this</p>
  
  <pre><code>$data = $data1 + $data2 + $data3;
  </code></pre>
  
  <p>I have tried and succeeded, but when one of the array is empty or unread it will error or not display any data even notification error</p>
  
  <p>And i try make "if and else" like this</p>
  
  <pre><code>if(empty($data1)){
      $data = $data2 + $data3;
  }
  elseif(empty($data2)){
      $data = $data1 + $data3;
  }
  elseif(empty($data3)){
      $data = $data1 + $data2;
  }
  else{
      $data = $data1 + $data2 + $data3;
  }
  </code></pre>
  
  <p>And page not show anything or blank, is there any other solution to solve this problem ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After all i use <code>array_merge()</code> to combine multiple array from @Saral and when some variable is empty i use code sample like this</p>
  
  <pre><code>if(empty($array)){
      $array = array();
  }
  </code></pre>
  
  <p>And then it's work, thank you.</p>