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;








-2















I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP



HK20271557

HK20271557









share|improve this question


























  • 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

















-2















I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP



HK20271557

HK20271557









share|improve this question


























  • 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













-2












-2








-2


1






I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP



HK20271557

HK20271557









share|improve this question
















I want access to addressLine, adminDistrict from address element which is stored in json format IN PHP



HK20271557

HK20271557






php json






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















0
















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)





share|improve this answer

























  • They asked for it IN PHP

    – Derek Pollard
    Mar 28 at 13:10


















0
















<?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/>";





share|improve this answer



























  • $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













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
);



);














draft saved

draft discarded
















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









0
















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)





share|improve this answer

























  • They asked for it IN PHP

    – Derek Pollard
    Mar 28 at 13:10















0
















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)





share|improve this answer

























  • They asked for it IN PHP

    – Derek Pollard
    Mar 28 at 13:10













0














0










0









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)





share|improve this answer













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)






share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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













0
















<?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/>";





share|improve this answer



























  • $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















0
















<?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/>";





share|improve this answer



























  • $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













0














0










0









<?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/>";





share|improve this answer















<?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/>";






share|improve this answer














share|improve this answer



share|improve this answer








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

















  • $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


















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?