$mystring = '{
"display_name": "Silverware",
"user": "joesmith",
"id": 27,
"field_name": "Age",
"sort_order": 1,
"required": 0,
"view_type": "text"
}';
我想要一个包含上述代码中所有键的 PHP 数组。最有效的方法是什么?
最佳答案
get all of the keys in this JSON with PHP
使用 json_decode
和 array_keys
函数的简短解决方案:
$keys = array_keys(json_decode($mystring, true));
关于php - 如何使用 PHP 获取此 JSON 中的所有 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41815474/