[Solved] getting implode to ignore a NULL value
Posted: Fri May 04, 2007 3:37 pm
I want to output addresses from a database. Not everyone has a subdistrict for their address so that key's value could be NULL
Trouble is implode doesn't ignore NULL values
To illustrate...
Outputs
Is there something simple I can do to make it less daft looking ?
Trouble is implode doesn't ignore NULL values
To illustrate...
Code: Select all
<?php
//simulated database mysql_fetch_assoc values
$addrow['add1']="street";
$addrow['add2']=NULL;
$addrow['town']="town";
$addrow['county']="county";
$addrow['postcode']="postcode";
$add=implode(", ",$addrow);
echo $add;
?>Code: Select all
street, , town, county, postcode