gpt4 book ai didi

javascript - 创建特定格式的 JSON 数据

转载 作者:行者123 更新时间:2023-11-28 19:47:20 24 4
gpt4 key购买 nike

我需要创建数据如下:

{v: 1.0, f: '<h1>1.0</h1>'}

...

但现在我只知道如何获取第一个参数,所以我得到:{v: 1.0} ,

使用此代码:

 $temp[] = array('v' => (string) $naziv);

我需要添加到我的代码中:$temp[] = array('v' => (string) $naziv);得到这样的json:{v: 1.0, f: '<h1>1.0</h1>'}

最佳答案

$naziv = 1.0;
$header ='<h1>1.0</h1>';

$temp[] = array('v' => (string) $naziv,
'f' => (string) $header
);

echo json_encode($temp);

$naziv = 1.0;
$header ='<h1>1.0</h1>';

$temp['v'] = $naziv;
$temp['f'] = $header;

echo json_encode($temp);

关于javascript - 创建特定格式的 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24064153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com