NotionCommotion Posted April 16, 2018 Share Posted April 16, 2018 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 Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted April 16, 2018 Solution Share Posted April 16, 2018 Try var_export. 1 Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 16, 2018 Share Posted April 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.