I'm building a function named buildTableFromArray() that will put data from an array into an HTML table, and would like to put the 'name' of the array into the top row of the table within a table header element. I have one solution where I pass the function 2 paramaters, the string name of the table, then the array name of the table, e.g. buildTablefromArray(musicians, $musicians) (where $musicians is the array holding musician names), but it bothers me that I cannot extract the string "musicians" from the passed parameter $musicians.
My first attempt was to just put the array in the table header, but then I just get the word Array as the heading. I've tried passing just the string name and adding a $ to it inside the function to refer to the array (in conjunction with making the array GLOBAL) but this gets me an empty array - I get the headers I want but empty <td> cells.
Is there a simple way to do this that I am missing? Maybe some function that allows me to grab the passed parameter and treat it as a string? I was not able to find such a function in my searches through the documentation, but I'm new enough to know that there's a lot I don't know. Any help will be greatly appreciated.