我需要生成以下JSON:
{
"title": "my form",
"fields": [
{
"type": "short_text",
"question": "What is your name?"
},
{
"type": "multiple_choice",
"question": "How often do you want to receive emails?",
"choices": [
{
"label": "Daily"
},
{
"label": "Weekly"
},
{
"label": "Monthly"
},]
},]
我正在尝试使用以下php代码:
$data = array(
"title" => "my form",
"fields" => array (
array (
"type" => "short_text",
"question" => "What is your name?"
),
array (
array (
"type" => "multiple_choice",
"question" => "How often do you want to receive emails?",
"choices" => (
array ("label" => "Daily")
),
(array ("label" => "Weekly")),
(array ("label" => "Monthly"))
)
)
)
);
$output = json_encode($data);
但它不起作用。
我非常感谢你们能提供的任何帮助!
<?php
$data = array (
'title' => 'my form',
'fields' =>
array (
array (
'type' => 'short_text',
'question' => 'What is your name?',
),
array (
'type' => 'multiple_choice',
'question' => 'How often do you want to receive emails?',
'choices' =>
array (
array (
'label' => 'Daily',
),
array (
'label' => 'Weekly',
),
array (
'label' => 'Monthly',
),
),
),
),
);
$output = json_encode($data);
?>