-1

i'm having structure of json like given below

{
    "today": {
        "currencyCode": "USD",
        "value": 100
    },
    "yesterday": {
        "currencyCode": "USD",
        "value": 90
    }
}

and i want to convert it to multi-dimentional array in php like given below:-

Array
(
    [today] => Array
        (
            [currencyCode] => USD
            [value] => 100
        )

    [yesterday] => Array
        (
            [currencyCode] => USD
            [value] => 90
        )

)
Script47
  • 14,230
  • 4
  • 45
  • 66
Parvej Alam
  • 258
  • 2
  • 8
  • 6
    [`json_decode($json, true)`](http://php.net/manual/en/function.json-decode.php) - [Live Example](https://repl.it/repls/OlivedrabDownrightCores) – Script47 Nov 28 '18 at 12:45

1 Answers1

1

like this,

    $json ='{
    "today": {
        "currencyCode": "USD",
        "value": 100
    },
    "yesterday": {
        "currencyCode": "USD",
        "value": 90
    }
}';

$data = json_decode($json, TRUE);


    var_dump($data);
Ugur Kazdal
  • 648
  • 8
  • 10