I have comma-separated value I get from multi-select option which is the id of mysql rows. I want to display it but I'm getting 'Notice: Array to string conversion' error using explode. My database table has columns of 'id, url' .

below are my code:

```
$imageids = '1,2,3,4';
$id = explode(',', $imageids);

$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

foreach ( $id as $img ) {

   $query = $pdo->prepare('SELECT url FROM kg_images WHERE id = :id');
   $query->bindParam(':id', $id);
   $data = $query->fetch(PDO::FETCH_ASSOC);

   echo '<img src="../content/uploads/'.$img[url].'">';

}

```

Any help please?