title: Merge an array with a string variable in PHP implode
body: <pre><code>implode(',', $a);
  </code></pre>
  
  <p>I want to attach the <code>$q</code> variable in front of the <code>$a</code> so like this</p>
  
  <pre><code>implode(',', $q.$a); 
  </code></pre>
  
  <p>But that doesn`t work. How can i put 2 variables in a implode function?</p>
  
  <p><code>$a</code> is an array with domain names like "com, org" and <code>$q</code> is the text (string) you type in before the domain names will appear. </p>
  
  <p>I get the following error: </p>
  
  <blockquote>
    <p>invalid argument passed in line..</p>
  </blockquote>
  
  <p>Whole code:</p>
  
  <pre><code>$a = ['nl','net','com','co'];
  $q = $_REQUEST["q"];
  
  $domain = explode(".", $q);
  $ext = @$domain[1] ?: ' ';
  
  
  if (empty($ext)) {
      echo implode(',',$a);
  } else if (in_array($ext, $a)) {
      echo $q;
  } else {
      $r = [];
      foreach ($a as $x) {
          if (strstr($x, $ext)) {
              $r[] = $x;
          }
      }
      echo (count($r)) ? implode(',',$r) : implode(',',$a);
  }
  </code></pre>