S
S
Sebastian Pereira2015-05-03 15:34:54
PHP
Sebastian Pereira, 2015-05-03 15:34:54

PHP: How to get value from json?

Hello, tell me how to parse json and get the value.
json:

array (size=2)
  'Items' => 
    array (size=2)
      0 => 
        array (size=3)
          'Id' => int 4064
          'Name' => string 'Имя bla'
          'Content' => string 'Bla имя это имя bla'
              ...
      1 => 
        array (size=3)
          'Id' => int 4052
          'Name' => string 'Имя quato'
          'Content' => string 'Uno ozairbagen'
)

Tried:
$results = json_decode($contents, TRUE); 
$results->Items[1]->Id;

Nothing succeeded. You can also suggest how to iterate over all values ​​in a loop.
*Learn how to use JSON.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Defman21, 2015-05-03
@Defman21

You specified the second argument for json_decode as TRUE, i.e. at the output you will get a regular PHP array, not an object.
$results['Items'][1]['id']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question