首页 > 解决方案 > 我想用 php 更新值 json

问题描述

想改一些,比如description,把value改成test2 form url json

{
  "title": "test",
  "description": "test",
  "keyword": "test",
  "ogimage": "test",
  "radio": "test",
  "noscript": "test",
  "fbpage": "test",
  "pagesID": "test",
  "payIMG": "test",
  "titlepay": "test",
  "font": "test"
}

标签: phpjson

解决方案


希望对你有帮助

<?php 
$jsonString = '{
  "title": "test",
  "description": "test",
  "keyword": "test",
  "ogimage": "test",
  "radio": "test",
  "noscript": "test",
  "fbpage": "test",
  "pagesID": "test",
  "payIMG": "test",
  "titlepay": "test",
  "font": "test"
}';
$data = json_decode($jsonString, true);
$data['description'] = "test2";
$data = json_encode($data);

推荐阅读