How can i improve this code? (implode/explode/unserialize)
<p>Im not satisfied im doing this the best way possible. Im taking serialized code from database column <em>location</em>. Im assuming that i have to implode the serialized data and then explode it because when i just use implode i cant access the entries in <em>counties</em> so i used explode. Im sure there's a better approach?</p>

<pre><code>$adid = $_GET['id'];
$query = "SELECT * FROM ad WHERE id = '$adid'";
$data = mysqli_query($dbc, $query);
$ad = mysqli_fetch_array($data);



 //retrieve serialized data containing county id's
    $counties = explode(" ", implode(" ", unserialize($ad['location'])));

for ($i = 0; $i &lt;= count($counties); $i++) {
echo getCounty($counties[$i]); //getCounty: enter county id and return county name
}


FYI: $ad['location'] = a:2:{i:0;s:1:"2";i:1;s:2:"20";}
</code></pre>
