json - Group array by value php
After selecting all the values from the table into a result array
$result = $stmt->fetchAll(PDO::FETCH_OBJ);
I want to created an array that contains groups for same session dates
Then pass it as JSON.
How do we group the result by session dates?
Something like this but instead of the dates "2018-04-01:" if it can be replaced with 0 and then 1,2...
Result something like this
Answer
Solution:
The question you are asking is more about the request than the result array. Can you edit your post to specify the request you have ?
In SQL, there is a "GROUP BY" parameter in order to make groups.
Answer
Solution:
You can alter your sql query and use the GROUP BY clause
Or possibly php array_values
Answer
Solution:
The following code helped me group the arrays