H
H
Homer_Simpson2014-11-29 23:46:59
PHP
Homer_Simpson, 2014-11-29 23:46:59

How to escape space when parsing json using php?

Got json

{
  "result": {
    "data": {
      "some data": {
        "foo": "bar"
      }
    }
      }
}

$EUW = ​​"{$parse->result->data->some data->foo}";
Tried some\data

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Chernyshev, 2014-11-30
@Homer_Simpson

$parse->result->data->{"some data"}->foo

N
Nazar Mokrinsky, 2014-11-30
@nazarpc

Alternatively, you can parse not into an object, but into an array, passing it trueas the second parameter json_decode(), but in general - the answer to your question is the second comment under the documentation page about json_decode(): https://php.net/manual/en/function.json-decode.php
Take a look there sometimes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question