-4

i have a json array like below,

{
    "months": {
        "1": ["1"],
        "2": ["10"]
    },
    "days": {
        "1": ["1", "2"],
        "2": ["2", "3"]
    }
}

i need to parse this in php. Need months and days values. Thanks in advance..

3
  • 3
    You did not search before posting Commented May 18, 2018 at 6:39
  • just use json_decode($json, true) ; it will convert json into array Commented May 18, 2018 at 6:51
  • Thanks bro @GautamRai.. Commented May 18, 2018 at 7:05

1 Answer 1

-1

why you don't use json_decode() function?

$json = '{
"months": {
    "1": ["1"],
    "2": ["10"]
},
"days": {
    "1": ["1", "2"],
    "2": ["2", "3"]
}
}';

$decoded = json_decode($json);
var_dump($decoded);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.