title: PHP inserting ellipsis in the middle(!) of a string?
body: <p>I am working on a PHP forum software (<a href="http://www.fluxbb.org" rel="nofollow noreferrer">FluxBB</a>) and a user encountered a rather interesting error, that - so it seems - PHP is inserting an ellipsis in the middle of a string.</p>
  
  <p>Due to a similar error I found on the net I feel forced to say that this code is situated in a function and that <code>$db</code> is a global variable.</p>
  
  <p>Here's the (simplified) code:</p>
  
  <pre><code>// Get unique words from the above arrays
  $unique_words = array_unique(array_merge($words['add']['post'], $words['add']['subject']));
  
  if (!empty($unique_words))
  {
      $result = $db-&gt;query('SELECT id, word FROM '.$db-&gt;prefix.'search_words WHERE word IN('.implode(',', preg_replace('#^(.*)$#', '\'\1\'', $unique_words)).')', true) or error('Unable to fetch search index words', __FILE__, __LINE__, $db-&gt;error());
  
      $word_ids = array();
      while ($row = $db-&gt;fetch_row($result))
          $word_ids[$row[1]] = $row[0];
  </code></pre>
  
  <p>Now, <code>$unique_words</code> consists of multiple French words (in this case), and the ellipsis gets added <strong>right before the comma and behind the closing quote</strong>. That must mean it is added during the implode call, which makes no sense at all.</p>
  
  <p>NOTE: Escaping the words is taken care of.</p>
  
  <p>In fact, only PHP can be causing the error, since the query that is spit out by the debugger is saved before being executed.</p>
  
  <p>I'm actually trying to give support, but I cannot come up with a reasonable solution...</p>