I have generated a “master” array which looks a little like this:
Array ( [userID] => 152 [email] => xxxxx@googlemail.com [name] => Jay jay go go [stream] => 616 )
Array ( [userID] => 133 [email] => damxxxxian@indigo.com [name] => Damian T [stream] => 616 )
Array ( [userID] => 154 [email] => julie@indigo.com [name] => Julie1000 E [stream] => 615 [PROGRAMME] => Designer )
Array ( [userID] => 153 [email] => jay@indigo.com [name] => James1000 G [stream] => 616 [PROGRAMME] => Apple Develpepr )
This is the output from a loop through a single array, so each of these 4 arrays are have keys 0 – 3.
My problem is that I want a table creating to hold all this data, with each row representing a user, but the array keys can be slightly different. For example, the first 2 users have no “programme” array key/value, but I want there to be a column saying “programme” but have it empty for users that dont have this in their array.
Hope that makes sense.
This can be accomplished by merging all of those arrays into a single array. Loop through every item in the array, gathering the keys (in_array might help there). Loop through your keys array to print out all the column headers in your table, then when your script needs to output the array you can simply run in a loop over each person, looping through each property as it maps to the column. That’s kind of abstract, but I think you can fill in the rest. Good luck!