Jump to content
Pardon our ads (a necessary update) ×

json to php array


neilfurry

Recommended Posts

hi mate, i have this json output and i need this to be in php array how can i do this,

 

 events : [
        {'id':1, 'start': new Date(year, month, day, 12), 'end': new Date(year, month, day, 13, 00), 'title': 'Lunch with Sarah', userId: [1, 2]},
        {'id':2, 'start': new Date(year, month, day, 14), 'end': new Date(year, month, day, 14, 40), 'title': 'Team Meeting', userId: 0},
     ],
free: [
        {'start': new Date(year, month, day-1, 8), 'end': new Date(year, month, day-1, 18), 'free': true, userId: [0,1,2,3]},
        {'start': new Date(year, month, day, 8), 'end': new Date(year, month, day+0, 18), 'free': true, userId: [0,1,2,3]},
     ]

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/299320-json-to-php-array/
Share on other sites

Your Json is not valid.



$json='{  
   "glossary":{  
      "title":"example glossary",
      "GlossDiv":{  
         "title":"S",
         "GlossList":{  
            "GlossEntry":{  
               "ID":"SGML",
               "SortAs":"SGML",
               "GlossTerm":"Standard Generalized Markup Language",
               "Acronym":"SGML",
               "Abbrev":"ISO 8879:1986",
               "GlossDef":{  
                  "para":"A meta-markup language, used to create markup languages such as DocBook.",
                  "GlossSeeAlso":[  
                     "GML",
                     "XML"
                  ]
               },
               "GlossSee":"markup"
            }
         }
      }
   }
}';

$array = json_decode($json, TRUE);
print_r($array);

Link to comment
https://forums.phpfreaks.com/topic/299320-json-to-php-array/#findComment-1525872
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.