To separate 'people_list_class' from 'display_name' I have a comma. But I only want the comma to show if the user have something written in the "people_lists_class"-field. Can I somehow integrate the following piece of code to accomplish this?

We store all of the information we need in variables that we pass along to our $html which means we can re-use the same variables over and over without making our code unnecessarily bloated with long verbose functions and function arguments to retrieve data. Not only that but its easier to read and if something goes wrong you'll find it much easier to debug your code than if you were doing it the other way around.