“foreach en el objeto json php” Código de respuesta

Php Loop a través de 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 en el objeto json 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

Respuestas similares a “foreach en el objeto json php”

Preguntas similares a “foreach en el objeto json php”

Más respuestas relacionadas con “foreach en el objeto json php” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código