Skip to content
Advertisement

Php foreach – separating each loop with comma except the last element

Heres what i mean:

JavaScript

current output would be:

JavaScript

i want the output to be like this:

JavaScript

(all ‘a’ separated with comma and when it comes to the last loop it doesnt write a comma)

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement