-1

How can I convert into an array into a specified array to be exact. Here's my string

data={"table":"users","fname":"mil","lname":"minoza","cntct":"09876543212"}

What I'm trying to achieve is something like this..

Array ( 
    [table] => users 
    [fname] => mil 
    [lname] => minoza 
    [cntct] => 09876543212 
)
Marius
  • 15,148
  • 9
  • 56
  • 76
Ligthers
  • 217
  • 1
  • 4
  • 10

3 Answers3

1

Try with this:

$input = 'data={"table":"users","fname":"mil","lname":"minoza","cntct":"09876543212"}';
$data = str_replace('data=', $input);
$data = json_decode(input , true);
krasipenkov
  • 2,031
  • 1
  • 11
  • 13
0
$data='{"table":"users","fname":"mil","lname":"minoza","cntct":"09876543212"}';
print_r(json_decode($data,true));
Amien
  • 954
  • 2
  • 11
  • 18
0

This is already asked by many people, you can search before you ask the question

Please go through the link.. This will be give solution for your question enter link description here

Mukesh
  • 150
  • 1
  • 10
  • Where's the question of the other people? So that I can see them as well. – Ligthers Oct 20 '16 at 09:47
  • This is one question, like what you have asked https://stackoverflow.com/questions/7511821/how-to-convert-json-string-to-array – Mukesh Jun 01 '17 at 09:16