“Foreach im JSON -Objekt PHP” Code-Antworten

PHP -Schleife durch JSON

$arr = json_decode('[{"var1":"9","var2":"16","var3":"16"},{"var1":"8","var2":"15","var3":"15"}]');

foreach($arr as $item) { //foreach element in $arr
    $uses = $item['var1']; //etc
}
Mobile Star

Foreach im JSON -Objekt PHP

object(stdClass)#5 (2) {
  ["status"]=>
  string(2) "ok"
  ["data"]=>
  object(stdClass)#19 (4) {
    ["id"]=>
    int(38037809)
    ["type"]=>
    string(4) "spot"
    ["state"]=>
    string(7) "working"
    ["list"]=>
    array(930) {
      [0]=>
      object(stdClass)#23 (4) {
        ["currency"]=>
        string(3) "ioi"
        ["type"]=>
        string(5) "trade"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      [1]=>
      object(stdClass)#30 (4) {
        ["currency"]=>
        string(3) "ioi"
        ["type"]=>
        string(6) "frozen"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      [2]=>
      object(stdClass)#28 (4) {
        ["currency"]=>
        string(3) "lun"
        ["type"]=>
        string(5) "trade"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      [3]=>
      object(stdClass)#33 (4) {
        ["currency"]=>
        string(3) "lun"
        ["type"]=>
        string(6) "frozen"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      [4]=>
      object(stdClass)#35 (4) {
        ["currency"]=>
        string(3) "ksm"
        ["type"]=>
        string(5) "trade"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      [5]=>
      object(stdClass)#15 (4) {
        ["currency"]=>
        string(3) "ksm"
        ["type"]=>
        string(6) "frozen"
        ["balance"]=>
        string(1) "0"
        ["seq-num"]=>
        string(1) "0"
      }
      }
Defiant Dormouse

Ähnliche Antworten wie “Foreach im JSON -Objekt PHP”

Fragen ähnlich wie “Foreach im JSON -Objekt PHP”

Weitere verwandte Antworten zu “Foreach im JSON -Objekt PHP” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen