php - 获取message中的值
阿神
阿神 2017-04-10 14:34:40
0
3
467
http://git.oschina.net/startbbs/startbbs/graph/master.json

这里是一段json数据,想获取message的值,循环出来。如何弄。 先转成数组,对吧

阿神
阿神

闭关修行中......

全部回复(3)
左手右手慢动作
<?php
    $message = array();
    $json = json_decode(
         file_get_contents('http://git.oschina.net/startbbs/startbbs/graph/master.json'),
         true);
    foreach($json['commits'] as $commit) 
         $message[] = $commit['message'];
    print_r($message);
?>
伊谢尔伦
<?php
    $message = array();
    $json = json_decode(
         file_get_contents('http://git.oschina.net/startbbs/startbbs/graph/master.json'),
         true);
    foreach($json['commits'] as $commit) 
         $message[] = $commit['message'];
    print_r($message);
?>
伊谢尔伦

用curl取得url里的json值,再json_decode得到数组$arr,循环$arr['commits']得到message的值

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板