Hi,
I'm trying to separate elements from an array with a comma and put the result into a string variable.
Here is my code:
for ($i=0; $i <$number_co_authors; $i++)
{
$required .= "co_aut".$co_author_row_number[$i]."last_name".","."co_aut".$co_author_row_number[$i]."first_name".","."co_aut".$co_author_row_number[$i]."institution".","."co_aut".$co_author_row_number[$i]."city".","."co_aut".$co_author_row_number[$i]."_country".",";
}
If I do:
echo $required;
it outputs the following:
co_aut1_last_name,co_aut1_first_name,co_aut1_institution,co_aut1_city,co_aut1_country,
Everything is ok except for the comma at the end. I can't find a way to get rid of it. I think my concatenation of the string is not right. Can someone help me? 🙂