Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow JSON to mysql with php

    Ok I understand how to get normal JSON files into php variables with json_encode(); However, the json file I'm working with looks something like this:

    Code:
    {"daily":
    {"1319846400000":250,"131993280000000",189"},"average":
    {"1319846400000":190,"131993280000000",189"}}
    There are 180 different daily prices with a 180 day running average (the long row of numbers is a timestamp in ms from Jan 1, 1970).

    My question is how do I import this data into a table with id, timestamp, price, 180_average, one row per day?

  • #2
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps I could take the array made by json_decode() and do a foreach() but it is still nested strangely. Possibly a double foreach()? Like:

    Code:
    foreach($out["daily"] as $myarray) {
         foreach ($myarray as $key => $value) {
        
         }
    }
    I don't really know where to go from there. Possibly turn each part on the array into a string and put those strings into the database. How would I do that? Sorry I have been away from php for a while

    http://www.webmasterworld.com/forum88/3811.htm this is what gave me the foreach() idea.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •