How to access data effectively in JSON PHP [duplicate] - php

This question already has answers here:
How can I access an array/object?
(6 answers)
Closed 5 years ago.
How do I get the data under [t]?
JSON data:
$array= json_decode($json);
echo "<pre>";
print_r($array[something blah blah]);
echo "</pre>"

Either you convert the json object to an array, or access it as an object:
$json->manga[0]->t;

Related

How to extract decode JSON from REDCap Array with PHP [duplicate]

This question already has answers here:
Why does this PHP code just echo "Array"?
(6 answers)
How to extract and access data from JSON with PHP?
(1 answer)
Closed 2 years ago.
I have an JSON Export from a REDCap and it started as a nested ARRAY. I use json_decode, but when I print the result I get an ERROR.
Here is the Array:
[{"record_id":"13","lastname":"Mustermann","first_name":"Json","dob":"1948-10-12","case_number":"1366613"}]
My Code is:
$deco = json_decode($json);
print $deco;
The line "echo" gives an error. What am I doing wrong?!
Thank you

PHP Traverse JSON data [duplicate]

This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 5 years ago.
I have a JSON output that looks like this:
{"data":[{"QID":"Q1234","MgrQID":"5678","NTID":"blah"}]}
I am trying to access just the data within the square brackets, inside the data array?
I have tried $jsonVar['data'] and $jsonVar->data and neither of them are working.
Is there a way I can just get access to [{"QID":"Q1234","MgrQID":"5678","NTID":"blah"}]?
Try this example:
<?php
$data = '{"data":[{"QID":"Q1234","MgrQID":"5678","NTID":"blah"}]}';
$test = json_decode($data, true);
echo json_encode($test['data']);
?>
Output:
[{"QID":"Q1234","MgrQID":"5678","NTID":"blah"}]

PHP Get Array Value from JSON Not working [duplicate]

This question already has answers here:
How to loop through PHP object with dynamic keys [duplicate]
(16 answers)
How to extract and access data from JSON with PHP?
(1 answer)
Closed 5 years ago.
I want to get the URLS from the JSON below.
$jsonArray = {
"uuid": "signed",
"PreSigned": "{'url': ['www.g.com', 'www.o.com']"}
I tried this $jsonArray -> PreSigned[0]->url
And it didn't work

Access JSON elements in PHP [duplicate]

This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 6 years ago.
I have some JSON data here http://pastebin.com/5VeJ5dda
How do I access ipaDownloadUrl on each case and put them in two variables in PHP?
I already did
<?php
$api = url_get_contents("http://example.com/api");
$decoded_api = json_decode($api);
?>
Now can you help me what to do next to get the specified elements?
You can access it like that:
<?php
$api = url_get_contents("http://example.com/api");
$decoded_api = json_decode($api);
echo $decoded_api['InfiniteApp']['ipaDownloadUrl'];
?>

I want to extract the number by key from a query string. [duplicate]

This question already has answers here:
Parse query string into an array
(12 answers)
Closed 7 years ago.
This is the value i get from db.
pkid=1&ordernumber=54322&ordervalue=12345&response=2&scheduleId=1
Want to extract response from this.That is 2.
Here it is
$str ='pkid=1&ordernumber=54322&ordervalue=12345&response=2&scheduleId=1';
parse_str($str);
echo $response; // output :- 2

Categories