d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php Help > Web Contents To Json Associative Array
Add Reply New Topic New Poll
Member
Posts: 29,344
Joined: Mar 27 2008
Gold: 504.69
Jan 24 2017 07:06pm
Getting a little tripped up here. Basically I want to access only the -1 from the following.

Code
$url = "...";
$lines_string=file_get_contents($url);
$jObj = json_decode($lines_string, true);
var_dump($jObj);


Resulting in:
Code
array(1) { ["result"]=> array(1) { [0]=> array(1) { ["id_login"]=> string(2) "-1" } } }


What I have tried.

echo $jObj[0]->id_login;
echo $jObj[0]['id_login'];

Any help appreciated.
Member
Posts: 29,344
Joined: Mar 27 2008
Gold: 504.69
Jan 24 2017 10:21pm
Don't know why it tripped me up for so long but got it.

Code
echo $jObj['result'][0]['id_login'];
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll