Echo array with string as separator
<p>I have the following code in PHP, which searches a file for lines containing a string:</p>

<pre><code>&lt;?php
echo "Results for: ";
echo ($_POST['query']);
echo "&lt;br&gt;&lt;br&gt;";
$file = 'completed.db';
$searchfor = ($_POST['query']);
header('Content-Type: text/plain');
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $contents, $matches)){
   echo "Found matches:\n";
   echo implode("\n", $matches[0]);
}
else{
   echo "No matches found";
}
?&gt;
</code></pre>

<p>In the line, <code>echo implode("\n", $matches[0]);</code> in echos an array, separated by spaces.  If I wanted to separate the items by a different string, say <code>$entry = '&lt;br&gt;'</code>, how would you do it?</p>

<p>For example, if <code>$matches</code> was</p>

<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>

<p>Then, the command should echo:</p>

<pre><code>one&lt;br&gt;two&lt;br&gt;three&lt;br&gt;
</code></pre>