gpt4 book ai didi

php - JavaScript 到 PHP 数组

转载 作者:行者123 更新时间:2023-11-28 13:48:27 24 4
gpt4 key购买 nike

假设我有这个:

var achievementData = {
"achievements": {
0: {
"id": 0,
"title": "All Around Submitter",
"description": "Submit and approved one piece of content in all six areas.",
"xp": 500,
"level_req": 3
},
1: {
"id": 1,
"title": "Worldwide Photographer",
"description": "Submit and approved one piece of image content in all six areas.",
"xp": 1200,
"level_req": 1
},
2: {
"id": 2,
"title": "Super Submitter",
"description": "Get approved 10 players and 2 clubs in one week or less.",
"xp": 2500,
"level_req": 5
},

}
};

这是 JavaScript,那么我如何将其转换为 PHP?我尝试更改括号并查找有关 PHP 数组的信息,但看起来这只是简单的示例。

最佳答案

您应该使用 json_decode() 将该字符串转换为 php 中有用的内容,将第二个参数设置为 true 它将为您提供一个关联数组。

http://php.net/manual/en/function.json-decode.php

关于php - JavaScript 到 PHP 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12450577/

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