php - Getting JSON values from url -


this first time using stackoverflow, if doing wrong asking question, let me know! :)

let's question.

i developing public api, php , json. first time me using json php, kind of new it.

the problem while getting values api (just wanted test out before let others use it)

i have no problems encoding it, have ran through multiple validators , hurlit, , works fine.

my guess there problem in retrieving code.

this response api

[{"recordid":"1","uuid":"5c298318-905e-3759-8762-150c7c77ef17","username":"fgh78","firstjoin":"2017-04-02","lastjoin":"2017-04-14","joincount":"81","lineswritten":"3545","currencyvalue":"0","rank":"default"}] 

and code use retrieving specific value.

$url = 'http://localhost/api.zunarmc.se/api/v1/stats/api.php?apikey=828137163&player=fgh78'; $json = file_get_contents($url); $array = json_decode($json, true);  echo $array->joincount; 

the response nothing, nothing @ when using code.

i want know if of nice folks on stackoverflow tell me wrong code or give me tips.

thank you! ~.~

here should notice second parameter json_encode.

array

$array = json_decode($json, true); echo $array['joincount']; 

object

$array = json_decode($json); echo $array->joincount; 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -