您可以将其与带有 json_encode 和 json_decode 的单个表一起使用
<?php
$patients = array();
$patients[0] = array(
'first_name' => 'john' ,
'last_name' => 'doe' ,
'diseases' => array ( 'Mood disorders' , 'Thyroid Cancer' , 'Migraine' ),
'medication' => array (
'pills' => array ( 'amoxicillin' , 'Vicodin' ) ,
'syrups' => array ( 'Zantac' , 'Invirase' ) ,
'surgeries' => array ( 'Urinary' , 'Ears' , 'Endocrine' )
)
);
$encode = json_encode($patients);
echo $encode;
// Output
//[{"first_name":"john","last_name":"doe","diseases":["Mood disorders","Thyroid Cancer","Migraine"],"medication":{"pills":["amoxicillin","Vicodin"],"syrups":["Zantac","Invirase"],"surgeries":["Urinary","Ears","Endocrine"]}}]
// sore above string in table
$decode = json_decode($encode, true);
echo "<pre>";
print_r($decode);
echo "</pre>";
//output
(
[0] => Array
(
[first_name] => john
[last_name] => doe
[diseases] => Array
(
[0] => Mood disorders
[1] => Thyroid Cancer
[2] => Migraine
)
[medication] => Array
(
[pills] => Array
(
[0] => amoxicillin
[1] => Vicodin
)
[syrups] => Array
(
[0] => Zantac
[1] => Invirase
)
[surgeries] => Array
(
[0] => Urinary
[1] => Ears
[2] => Endocrine
)
)
)
)
</pre>