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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

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