trying to figure out a way to have all of these items assigned as PHP variables for another script that would insert them into a MYSQL database.
So far have this
$url = "[we would have the url where the JSON data is available here that would produce the output seen in the example above]"
$json = file_get_contents($url);
$out = json_decode($json,true);
If I output $out to a file, I get this
Array
(
[success] => 1
[numResults] => 1
[execTimeMs] => 10
[results] => Array
(
[0] => Array
(
[testAccount] => testingaccount1
[testnotes] => Array
(
[test_department] => creative
[test_office_location] => 98th Floor
)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
They are already in array variables, so there is really no need to assign them to other variables. Since you did not wrap your output in [code]...[/code] tags here, it's difficult to see the hierarchy/nesting; but for example, if you want to reference the "testingaccount1" value, it would appear to be:
PHP Code:
$out['results'][0]['testAccount']
.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
trying to figure out a way to have all of these items assigned as PHP variables for another script that would insert them into a MYSQL database.
So far have this
PHP Code:
$url = "[we would have the url where the JSON data is available here that would produce the output seen in the example above]"
$json = file_get_contents($url);
$out = json_decode($json,true);
They are already in array variables, so there is really no need to assign them to other variables.
but for example, if you want to reference the "testingaccount1" value, it would appear to be:
PHP Code:
$out['results'][0]['testAccount']
I understand what you are saying there. I should have used the multiple result example as it is more relevant to the point of my question - so I'll provide and example output for $out with a multiple result JSON decode
So when we have these decoded JSON results, there may be anywhere from 1 to 200 results. So each individual result set starts with
Code:
[0] => Array
then the next result set is
[1] => Array
and the next
[2] => Array
and so on.....
We need to take each of the items from each result set and inject them into a MYSQL Table that contains matching fields. Just not sure the easiest way to do this since the result set numbers change and the number of results can be different each time.
(Obviously you want to do something other than just echo stuff in the loop. )
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks