I have this code:
function setWeek($week) {
preg_match_all("/[\d\/]+/", $week, $output, PREG_SET_ORDER, 0);
$this->week = array("week" =>
array('id' => $output[0][0], "start" => $output[1][0], "end" => $output[2][0]));
$json = json_encode($this->week);
echo $json;
}
It returns me this:
{"week":{"id":"247","start":"12\/04\/18","end":"19\/04\/18"}}{"week":{"id":"246","start":"05\/04\/18","end":"12\/04\/18"}}
But this form is wrong as it is multiple JSON's I would need to add [] and ',' How could I do this to stay like this:
[{"week":{"id":"247","start":"12\/04\/18","end":"19\/04\/18"}},{"week":{"id":"246","start":"05\/04\/18","end":"12\/04\/18"}}]