How can I parse this JSON? [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I can't get the "img_url" (on third line) value from the JSON using PHP. Here's the JSON string:
Edit (This is the JSON, my apologies for posting the var_dump):
{"status_code":200,"status_txt":"OK",
"data":{"img_name":"KdxIC.png","img_url":"http:\/\/s0.uploads.im\/KdxIC.png",
"img_view":"http:\/\/uploads.im\/KdxIC.png","img_width":"504","img_height":"504",
"img_attr":"width=\"504\" height=\"504\"","img_size":"15.1 KB","img_bytes":15494,
"thumb_url":"http:\/\/s0.uploads.im\/t\/KdxIC.png","thumb_width":360,"thumb_height":360,
"source":"http:\/\/site.com\/uploads\/icon1#2x.png","resized":"0","delete_key":"6e814d3c5201feee"}}
The accepted answer works. Thanks

That code is not json, its a php dump of an array.
If you want to access the image url do this:
I'm using this example url.
$imgdata = json_decode($response, true);
echo $imgdata["data"]["img_url"];
Output:
http://s0.uploads.im/go0WK.png
Edit:
Do not use the second param in json_decode, that is converting your object to an array.

Related

Display JSON Value from URL using PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How does one display the USD exchange rate from https://bitpay.com/api/rates using PHP on a web page?
ie, that in the first line:
{"code":"USD","name":"US Dollar","rate":325.8}
you need json_decode() from php
it will convert the json data to a php object
but as suggested by Marc B
write some code

mongo:db.users.find({"addressse.0.state":"NY"}) write in php? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In learing mongo with php,I have a tiny problem,
that is all,any help would be great appreciated!
You need to read this MongoPHPQueries Page and probably before that you need to do as #RocketHazmat said and start with this MongoPHP Tutorial.
But here is something that might help you with the data you are trying to find.
$cursor = $collection->find(array("addressse.0.state" => "NY"));
The above will give you a cursor allowing you to iterate over each record that is returned. Hope this helps.
FYI - You need more than just that line above to get that to work. So follow the links.

GPS Location Coordinaties in PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I write a code that gets the current location coordinates (LLA) in my web browser using PHP .
Is it possible by using GPS via HTTP or something like that ?
please help
Thanks
You will need to use the brower's geolocation API, for example as shown here.
Then, you simply pass the parameters to a PHP script using whatever method you like, a form, or a jQuery post.

Grab part of an URL in PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this link viewdocument.php?a=http%3A%2F%2Fwww.iesalfonsox.com%2Fimages%2FLIBROS_ESO_13-14.pdf in (for example) index.php and I want to put only the URL of the document of the link.
Example:
Link: http://www.myweb.com/viewdocument.php?a=some.pdf
On the HTML: You're viewing "Some.pdf".
Do you understand? Convert "viewdocument.php?a=some.pdf" to "some.pdf".
If this is the current URL being accessed on your site, Php provide globals and you can access it using the $_GET variable:
so for your example you will use this:
$file = $_GET['a']; // will return some.pdf
The other case will be for parsing a url from a string, for which php provides a function:
parse_url();
Follow the link to see examples

How to get jQuery variable value in PHP file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I need to jQuery variable value in PHP code in same file with out calling ajax? Please help me it is possible or not. Here jQuery and PHP code here given below.
well you can make use of jquery.session plugin to store Session variable and then you can access that variable using php code.
Sample Code
$(function() {
$.session("myVar", "value");
});
In PHP
echo $_SESSION['myVar'];

Categories