Question: I have this simple for loop to echo an array:

```
for ($i = 0; $i < count($director); $i++) {
   echo '<a href="person.php?id='.$director[$i]["id"].'">'.$director[$i]["name"].'</a>';
}

```

The problem here is that when more than one element is in the array then I get everything echoed without any space between. I want to separate each element with a comma except the last one.

I can't use `implode` so I'm looking for another solution

Answer: 
My preferred method:

```
$links = [];
for ($i = 0; $i < count($director); $i++) {
  $links[] = '<a href="person.php?id='.$director[$i]["id"].'">' .
      $director[$i]["name"] . '</a>';
}
echo implode(', ', $links);

```

Or 

```
$output = "";
for ($i = 0; $i < count($director); $i++) {
  if ($output) {
    $output .= ", ";
  }
  $output .= '<a href="person.php?id='.$director[$i]["id"].'">' .
      $director[$i]["name"].'</a>';
}
echo $output;

```
Here's my 2 lines solution 

```
// Create your Array
$cities = Array("Rome", "Florence", "Venice");

// implode them
$list = trim(implode (", ", $cities))  ;
// remove last comma
$list = substr ( $list,0 ,strlen( $list ) );

//check result
die ($list);

```