php - Insert array into multidimensional array -


I have an array that looks like this:

  { "calendar": { "date": "1", "event": "1", "description": "", "address": "laboratory"}}   

and I have a new array input I want to get this output in this array, but inside the calendar:

  {"calendar": {"date": "1", "event": "1" , "Code": "code": "code": "lab"} {"" "" "" 2 "," event ":" 2 "," description ":" "," code ":" laboratory "}}   

All of this is happening with a form post

  & lt ;? php $ Di_det = $ _get [ 'Di_det']; $ Di_ivent = $ _get [ 'Di_ivent']; $ Di_diskripshn = $ _get [ 'Di_diskripshn']; $ Di_kod = $ _get [ 'Di_kod'] ; $ Calendar = array ( "calendar" = & gt; array ( "Date" = & gt; $ dy_date, "event" = & gt; $ dy_event, "description" = & gt; $ dy_description, "code" = & gt; $ dy_code)); $ Calendar_check = json_decode (file_get_contents ( '../ calendar_dynamic.js'), true); $ Updated_cal = array (); Forex Currency ($ calendar_check $ as data) {$ updated_cal ["date"] = $ dy_date; $ Updated_cal ["event"] = $ dy_event; $ Updated_cal ["description"] = $ dy_description; $ Updated_cal ["code"] = $ dy_code; $ Updated_cal = array_merge ($ calendar_check ['calendar'], $ updated_cal); $ Filename = "../calendar_dynamic.js"; File_put_contents ($ filename, json_encode ($ updated_cal), FILE_APPEND); }? & Gt;   

I am unable to merge the array added to the correct location in the current array.

Thoughts

Try it

  $ Filename = "../uc3_stats/calendar_dynamic.js"; $ Dy_date = $ _GET ['dy_date']; $ Dy_event = $ _GET ['dy_event']; $ Dy_description = $ _GET ['dy_description']; $ Dy_code = $ _GET ['dy_code']; $ Newentry_calendar = array ( "Calendar" = & gt; array ( "Date" = & gt; $ dy_date, "event" = & gt; $ dy_event, "description" = & gt; $ dy_description, "code" = & gt ; $ Dy_code)); $ Old_calendar = json_decode (file_get_contents ($ filename, is true); $ New_calendar = $ old_calendar; // Keep the old entries $ new_calendar ['calendar'] [] = $ newentry_calendar ['calendar']; // Add new entry file_put_contents ($ filename, json_encode ($ new_calendar)); // save to file   

you can shorten it if you want, but it is close to your code;)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -