Home > Article > Backend Development > How to modify the value specified in json in php
How to modify the value in json in php: first set the "curl_setopt" option, including the URL; then execute and obtain the content of the HTML document; and finally release the curl handle.
php modifies the value specified in json
<?php header("content-type:text/html;charset=utf-8"); $postid=$_REQUEST['postid']; $url =""; $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //执行并获取HTML文档内容 $output = curl_exec($ch); $arr = json_decode($output,true); $getcom=$arr['auto'][0]['comCode']; include_once("kuaidi_config.php"); $url =""; //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //执行并获取HTML文档内容 $output = curl_exec($ch); //释放curl句柄 curl_close($ch); $obj=json_decode($output, true); foreach($obj as $key=>$value){ $obj['com']="中通"; } echo json_encode($obj); ?>
For more related knowledge, please visit PHP Chinese net!
The above is the detailed content of How to modify the value specified in json in php. For more information, please follow other related articles on the PHP Chinese website!