0

I have a json file where I try to get the first value (the hash) but have absolutely no idea how.

"usersauth": {
    "nufj48597sdfnvsdf7": 23972
}

when I try to get this data with

$userauth = $decode['usersauth']; and $userauth = $decode['usersauth'][0];

both tries dont work. The first saves "Array" in database, the second just a blank field. Would be very happy if someone has an idea how this works. I searched for 2 days on google but could not find anything about it.

LearningToCode
  • 392
  • 5
  • 18
  • `$decode['usersauth']->nufj48597sdfnvsdf7` It looks like an object to me not an array. But if you were to have shown us more code we could be more helpful – RiggsFolly Jul 24 '18 at 18:22
  • foreach($decode['usersauth'] as $key => $value) { echo "key :" . $key . " value :" . $value } – siddhesh Jul 24 '18 at 18:23
  • the problem is i dont know what is in there. so i cant use ['userauth']->'somehash'; i get an json file catch it with php//input and json_decode it then access the data. its the only time i ever saw something like that. – Mahony Production Jul 24 '18 at 18:25
  • use my code dude it will surely help you – siddhesh Jul 24 '18 at 18:27
  • ok thank you siddhesh i will try it right now – Mahony Production Jul 24 '18 at 18:28
  • Assuming you have parsed the JSON correctly, just use `var_dump($decode['usersauth'])` and see what is output. This will show if its an array etc and should show the content. Be aware if their is a lot of nested arrays etc var_dump will just output `...` – PanPipes Jul 25 '18 at 15:39

0 Answers0