Converting array to json data in PHP

Viewed 14

when I print the array I created with php to the screen with the print_r function, it looks normal.

But when I convert it to json data with the json_encode function, the keys are lost. I tried a lot but couldn't find a solution.

Thank you in advance for your help. function -> print_r

 [1] => Array
        (
            [succes] => 1
            [title] => Test Title
            [0] => Array
                (
                    [0] => car
                    [1] => bus
                    [2] => a
                    [3] => b
                    [4] => c
                    [5] => d
                )

        )

Json function -> json_encode

{
"0": [
  "car",
  "bus",
  "a",
  "b",
  "c",
  "d"
],
“succes”: "1",
“Title”: “Test Title”
  }

0 Answers
Related