php - 问题将json文件转换为php中的数组
问题描述
这是来自 $_POST 的数据恢复
$list =
array(0=>$_POST['matricule'],1=>$_POST['nom'],2=>$_POST['prenom'],3=>$_POST['dn'],4=>$_POST['tel'],5=>$_POST['mail'],6=>$_POST['sexe'],7=>$_POST['adresse']);
$contenu_json = json_encode($list);
fwrite($fp, $contenu_json); // "test.json"
这个示例导致 test.json :
["123","test","test","test","test","test","test","test"]["2","test","test","test","","","",""]
示例代码 2:
$json_source = file_get_contents("test.json");
$data = json_decode($json_source, true);
echo '$data[1]';
输出 $data[0] 是 "" :( 。我想看 "123"
My objectif is to see all data json in form like :
<input name="id" type="text" value="<?= $data[0] ?>" >
有什么问题?
解决方案
推荐阅读
- database - SQLite3 查询 COUNT 组合两个表
- python - 如何将多个值添加到键字典
- django - Select2 仅将一个选择传递给 Django 中的表单
- spring - 如何从授权中获取 jwt 令牌
- jinja2 - jinja2.exceptions.TemplateSyntaxError:模板意外结束。Jinja 正在寻找以下标签:'endblock'
- java - ListLiterator 是 Iterator 的子类吗
- python - 从指向 CSV 的 URL 创建字典列表
- python-3.x - 如何使用熊猫删除重复值并保留任何一个
- haskell - 在 Haskell 中创建自定义标志
- c# - SQL Server 和 C# DateTime 中的日期比较