I have an array with film information and the times when they will be shown in the cinema. each showing is another result, so one film can be in the array multiple times. I want to combine duplicate film entries into one and put all shows in another dimension in the new array. The formatting is this:
Array (
[title] => title
[synopsis] => synopsis
[poster] => poster
[cast] => cast
[director] => director
[length] => length
[rating] => rating
[datetime] => datetime )
Should be formatted into:
Array (
[title] => title
[synopsis] => synopsis
[poster] => poster
[cast] => cast
[director] => director
[length] => length
[rating] => rating
[datetime] => Array
( [0] => datetime0
[1] => datetime1
... )
)
Has anyone an idea how to combine it after "title" and put all entries for datetime in a new dimension. Thank for your help!
SELECT * from films GROUP BY title?GROUP BYandGROUP_CONCAT()in your SELECT. After you have created a comma-separate list of showtimes, when you want to present the data, just explode on the commas. This will also let you sort the result set based on the film name and generally pack much of the logic in your query -- where it will be easiest to read and manage. Next time that you ask a question, be sure to include your best coding attempt -- it is expected.