解析 JSON 数据

admin 2018-2-7 1817

$json_string='{"id":1,"name":"rolf","country":"russia","office":["google","oracle"]} ';
$obj=json_decode($json_string);//print the parsed dataecho
$obj->name; //displays rolfecho
$obj->office[0]; //displays google


欢迎联系本站长QQ:3216572
最新回复 (1)
  • admin 2018-2-7
    2
    34.  根据  URL  下载图片

    function  imagefromURL($image,$rename)
    {
    $ch  =  curl_init($image);
    curl_setopt($ch,  CURLOPT_HEADER,  0);
    curl_setopt($ch,  CURLOPT_RETURNTRANSFER,  1);
    curl_setopt($ch,  CURLOPT_BINARYTRANSFER,1);
    $rawdata=curl_exec  ($ch);
    curl_close  ($ch);
    $fp  =  fopen("$rename",'w');
    fwrite($fp,  $rawdata); 
    fclose($fp);
    }
    语法:

    <?php
    $url  =  "http://koonk.com/images/logo.png";
    $rename  =  "koonk.png";
    imagefromURL($url,$rename);
    ?>
返回
发新帖
作者最近主题: