Use json_encode()
to store data in mysql table.
<?php
$name= "prashant";
$lname= "kumbhar";
$test = "testing";
$array = array('fname'=>$name,
'lname'=>$lname,
'test' => $test
);
$res = json_encode($array);
echo "Convert from array to json :" .$res;
echo "\n\nFrom json to array:\n";
print_r(json_decode($res));
output
Convert from array to json :
{"fname":"prashant","lname":"kumbhar","test":"testing"}
From json to array:
stdClass Object
(
[fname] => prashant
[lname] => kumbhar
[test] => testing
)
At the time of retrieve data in array form then use json_decode()
Working Demo : Click Here