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
implodeonly works when you have already an array of elements to "implode" (of course one could generate a list of the HTML beforehand and then implode but this seems unnecessary to me).implodewould be appropriate here, I don't see why the question needs to be limited by some unreasonable conditions.