Jump to content

Obtain PHP array definition script based on JSON


NotionCommotion

Recommended Posts

I was in process of typing the PHP script such as $arr=['a'=>[],'b'=>['c'=>123]]; necessary to create an array which is based on a fairly large JSON object.  To save me some time, I used print_r(json_decode($myObj,true)); and it helped a little, but not much.  I will just keep plugging along, but I find myself doing this every now and then, and it would be nice to somehow generate the script.automatically.  Are any tricks available?  Thanks

Link to comment
Share on other sites

I really have no idea what you are asking. Are you creating the array or are you retrieving the array from some source?

 

You state

 

 

create an array which is based on a fairly large JSON object.

 

So, do you have a specific object with a predetermined format that you must create data for? Depending on the complexity of that data structure, how often I need to create a new data set, etc. I would take different approaches. E.g. I might have a pre-filled array with some default values or placeholders, I might use an Excel document where I have inputs for the various values and some code that puts them into the pre-formatted array, I might create a PHP application to do it, etc. etc.  

Link to comment
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.