-3

I want to be able to convert my JSON object into an array is there a built in function in php that allows me to do this?

Here is my json object:

in_userid: "38"
in_email: "user@email.com"
in_firstname: "John"
in_lastname: "Mason"
in_mobilenumber: "00000000000"
in_password: "pass12345"
in_phonenumber: "0000000"

and I want it to look something like this:

Array(
     in_userid => "38",
     in_email => "user@email.com",
     in_firstname => "John",
     in_lastname => "Mason",
     in_mobilenumber => "00000000000",
     in_password => "pass12345",
     in_phonenumber => "0000000",
);

How will I do this?

Nomad
  • 613
  • 2
  • 7
  • 15
  • 2
    `json_decode($json, !0);` – Class Sep 27 '14 at 02:59
  • 1
    can't you just search your title in google? – Kevin Sep 27 '14 at 02:59
  • Please try to perform at least the most basic search before posting a question. This is very very basic (that in itself isn't a problem) and has been asked and answered many many times (that is a problem). – Fluffeh Sep 27 '14 at 03:03

1 Answers1

0

use json_decode(). It takes a JSON encoded string and converts it into a PHP variable. See the json_decode function in the docs.

jww
  • 97,681
  • 90
  • 411
  • 885
Anthony Gainor
  • 1,149
  • 2
  • 10
  • 9
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – WebChemist Sep 27 '14 at 03:34
  • @WebChemist thanks for the advice, will definitely keep in mind for the next time. – Anthony Gainor Sep 27 '14 at 04:59