title: PHP array and implode with blank/null values
body: <p>I have a array which i generated by values in a database, the example is below:</p>
  
  <pre><code>$addressarray = array($results['client']-&gt;client_city, $results['client']-&gt;client_county, $results['client']-&gt;client_postcode);
  </code></pre>
  
  <p>The values are entered by the user using a from, the above array works and the correct values are placed into it, however sometimes the user may not enter the clients county, so therefore </p>
  
  <pre><code>$results['client']-&gt;client_county
  </code></pre>
  
  <p>may be blank.
  I call the array with this.</p>
  
  <pre><code>$address = implode("\n  ", $addressarray);
  </code></pre>
  
  <p>Now this is the part that i think need fixing, obviously if all the fields have a value then they are displayed with line breaks, but if like i mentioned above the county is blank it will stll output a line break so you will get:</p>
  
  <pre><code>city
  
  postcode
  </code></pre>
  
  <p>but what i want is </p>
  
  <pre><code>city
  postcode
  </code></pre>
  
  <p>I guessing the </p>
  
  <pre><code>\n
  </code></pre>
  
  <p>is the issue but am at a blank. any help appreciated.</p>
  
  <p>Ian</p>