Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Displaying Item Details

Joe Elia
Joe Elia
552 Points

[SOLVED] Remove extra Comma for last Author?

How would you remove the extra ", " for the last author in the string array.

Its in the video, just before the 4:00 mark. Using implode() on the array.

Joe Elia
Joe Elia
552 Points

Okay I understand the 'implode()' part, but it will still add a ", " to the last author ex: "Sarah Jean, Mike Jones, Carrie Blue, ". How would you remove ", " at the end of only "Carrie Blue.

Hi Joe,

There must be something else going on then. implode() won't add the glue string after the last element in the array. Only between each element.

I don't see a trailing comma in the video after the authors and I also don't have one in my personal files.

Does this happen for you on all 4 books? Change the id in the url to one of the other books.

Can you post the td that contains the author output? Maybe even post what one of your author arrays looks like in the data.php file.

Joe Elia
Joe Elia
552 Points

Oh y'all are right, I didn't see that the authors went down to the line below........

That makes sense. Glad you figured it out.

added [SOLVED] to title