how to access a address element from below nested json object IN PHPDeleting an element from an array in PHPAdd new attribute (element) to JSON object using JavaScriptHow to get the client IP address in PHPReturning JSON from a PHP ScriptHow can I parse a JSON file with PHP?How do I turn a C# object into a JSON string in .NET?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Parse JSON code from Bing Map API in C#How do I pass variables and data from PHP to JavaScript?How to deserialize bing map json using C#?
A command to output each line forward then backwards
What organs or modifications would be needed for a life biological creature not to require sleep?
How does doing something together work?
Why my Render has black outlines?
Why does dd not make working bootable USB sticks for Microsoft?
Amortized Loans seem to benefit the bank more than the customer
How do certain apps show new notifications when internet access is restricted to them?
Why don't airports use arresting gears to recover energy from landing passenger planes?
Pronunciation of "солнце"
Can an infinite series be thought of as adding up "infinitely many" terms?
Seven Places at Once - Another Google Earth Challenge?
Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?
Bit one of the Intel 8080's Flags register
Python web-scraper to download table of transistor counts from Wikipedia
How would you translate Evangelii Nuntiandi?
Transit visa to Hong Kong
What is the origin of the "being immortal sucks" trope?
geschafft or geschaffen? which one is past participle of schaffen?
Why is it called a stateful and a stateless firewall?
How to give my students a straightedge instead of a ruler
Are there any “Third Order” acronyms used in space exploration?
How would you control supersoldiers in a late iron-age society?
What is the word for a person who destroys monuments?
Answer Not A Fool, or Answer A Fool?
how to access a address element from below nested json object IN PHP
Deleting an element from an array in PHPAdd new attribute (element) to JSON object using JavaScriptHow to get the client IP address in PHPReturning JSON from a PHP ScriptHow can I parse a JSON file with PHP?How do I turn a C# object into a JSON string in .NET?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Parse JSON code from Bing Map API in C#How do I pass variables and data from PHP to JavaScript?How to deserialize bing map json using C#?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP
HK20271557
HK20271557
php json
add a comment
|
I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP
HK20271557
HK20271557
php json
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27
add a comment
|
I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP
HK20271557
HK20271557
php json
I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP
HK20271557
HK20271557
php json
php json
edited Mar 28 at 13:08
Code war
asked Mar 28 at 12:52
Code warCode war
94 bronze badges
94 bronze badges
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27
add a comment
|
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27
add a comment
|
2 Answers
2
active
oldest
votes
you need to access it by assigning it to the variable e.g. say
let a = HK01EAP000001D0"
then access it like this
console.log(a.resourceSets[0].resources[0].address)
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
add a comment
|
<?php
/*
if Array of JSON Object is returned then
Use following
*/
$json = '[HK20271557,
HK20271557]';
$array = json_decode($json);
foreach($array as $sub_array)
echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
/*
And if single JSON Object is returned then
Use following
*/
$json = 'HK01EAP000001D0"
';
$JsonData = json_decode($json);
echo $JsonData->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $JsonData->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398144%2fhow-to-access-a-address-element-from-below-nested-json-object-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
you need to access it by assigning it to the variable e.g. say
let a = HK01EAP000001D0"
then access it like this
console.log(a.resourceSets[0].resources[0].address)
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
add a comment
|
you need to access it by assigning it to the variable e.g. say
let a = HK01EAP000001D0"
then access it like this
console.log(a.resourceSets[0].resources[0].address)
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
add a comment
|
you need to access it by assigning it to the variable e.g. say
let a = HK01EAP000001D0"
then access it like this
console.log(a.resourceSets[0].resources[0].address)
you need to access it by assigning it to the variable e.g. say
let a = HK01EAP000001D0"
then access it like this
console.log(a.resourceSets[0].resources[0].address)
answered Mar 28 at 13:02
Taj KhanTaj Khan
3804 silver badges16 bronze badges
3804 silver badges16 bronze badges
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
add a comment
|
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
They asked for it IN PHP
– Derek Pollard
Mar 28 at 13:10
add a comment
|
<?php
/*
if Array of JSON Object is returned then
Use following
*/
$json = '[HK20271557,
HK20271557]';
$array = json_decode($json);
foreach($array as $sub_array)
echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
/*
And if single JSON Object is returned then
Use following
*/
$json = 'HK01EAP000001D0"
';
$JsonData = json_decode($json);
echo $JsonData->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $JsonData->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
|
show 3 more comments
<?php
/*
if Array of JSON Object is returned then
Use following
*/
$json = '[HK20271557,
HK20271557]';
$array = json_decode($json);
foreach($array as $sub_array)
echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
/*
And if single JSON Object is returned then
Use following
*/
$json = 'HK01EAP000001D0"
';
$JsonData = json_decode($json);
echo $JsonData->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $JsonData->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
|
show 3 more comments
<?php
/*
if Array of JSON Object is returned then
Use following
*/
$json = '[HK20271557,
HK20271557]';
$array = json_decode($json);
foreach($array as $sub_array)
echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
/*
And if single JSON Object is returned then
Use following
*/
$json = 'HK01EAP000001D0"
';
$JsonData = json_decode($json);
echo $JsonData->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $JsonData->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
<?php
/*
if Array of JSON Object is returned then
Use following
*/
$json = '[HK20271557,
HK20271557]';
$array = json_decode($json);
foreach($array as $sub_array)
echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
/*
And if single JSON Object is returned then
Use following
*/
$json = 'HK01EAP000001D0"
';
$JsonData = json_decode($json);
echo $JsonData->resourceSets[0]->resources[0]->address->addressLine . "<br/>";
echo $JsonData->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>";
edited Mar 28 at 13:54
answered Mar 28 at 13:27
Vipin Kumar SoniVipin Kumar Soni
7418 silver badges18 bronze badges
7418 silver badges18 bronze badges
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
|
show 3 more comments
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
$JsonData = json_decode($result,true); foreach ($JsonData as $sub_array) echo $sub_array->resourceSets[0]->resources[0]->address->addressLine . "<br/>"; echo $sub_array->resourceSets[0]->resources[0]->address->adminDistrict . "<br/>"; blank page is coming
– Code war
Mar 28 at 13:36
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
Please check that I have made the json response as array.Notice The Square brackets and comma in between json objects.
– Vipin Kumar Soni
Mar 28 at 13:39
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
but that is coming from an api, how can i change it,into the above format
– Code war
Mar 28 at 13:41
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning in that exact format. And please remove the second parmeter from json_decode($result,true) and change it to json_decode($result).
– Vipin Kumar Soni
Mar 28 at 13:42
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
Is the API is returning one json Object OR the whole that you have given in Question
– Vipin Kumar Soni
Mar 28 at 13:45
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398144%2fhow-to-access-a-address-element-from-below-nested-json-object-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
assign that JSON to a variable in PHP. And use json_decode() on that variable
– Vipin Kumar Soni
Mar 28 at 13:16
why to use json_decode(),when it is already coming in json format
– Code war
Mar 28 at 13:23
to convert it in array
– Vipin Kumar Soni
Mar 28 at 13:24
$JsonData = json_decode($result,true), and how to access the addressline from the array
– Code war
Mar 28 at 13:25
check the answer...
– Vipin Kumar Soni
Mar 28 at 13:27