需要使用php解析一下json

{
"result": [
    {
        "id": "186aae94e415",
        "photo": "http://pics.***.co.jp/digital/video/ebod00776/ebod00776pl.jpg",
        "name": "ツンれまのん",
        "lineTime": "2020-12-23",
        "lables": [
            "巨*",
            "口*",
            "內*",
            "通*"
        ],
        "score": 4.3,
        "movieType": 0,
        "canLoad": true,
        "todayNewMovie": false,
        "newCloudTime": "2020-12-23",
        "czn": true,
        "fanNum": "eb**776",
        "director": "TAKE-D"
    },
    {
        "id": "b78adf7e4ff8",
        "photo": "http://pics.***.co.jp/digital/video/ebod00682/ebod00682pl.jpg",
        "name": "あすかさん 26歳",
        "lineTime": "2020-05-27",
        "lables": [
            "骨*",
            "巨*",
            "內*",
            "*交",
            "通*"
        ],
        "score": 4.7,
        "movieType": 0,
        "canLoad": true,
        "todayNewMovie": false,
        "newCloudTime": "2020-05-27",
        "czn": true,
        "fanNum": "eb**682",
        "director": "----"
    },
    {
        "id": "b78adf7e4ff8",
        "photo": "http://pics.d****.co.jp/digital/video/ebod00682/ebod00682pl.jpg",
        "name": " あすかさん 26歳",
        "lineTime": "2020-05-27",
        "lables": [
            "骨*",
            "巨*",
            "內*",
            "*交",
            "通*"
        ],
        "score": 4.7,
        "movieType": 0,
        "canLoad": true,
        "todayNewMovie": false,
        "newCloudTime": "2020-05-27",
        "czn": true,
        "fanNum": "sti**664",
        "director": "----"
    }
]
}


完整代码如下:

<?php
$s ='{"result":[{"id":"186aae94e415","photo":"http://pics.***.co.jp/digital/video/ebod00776/ebod00776pl.jpg","name":"ツンれまのん","lineTime":"2020-12-23","lables":["巨*","口*","內*","通*"],"score":4.3,"movieType":0,"canLoad":true,"todayNewMovie":false,"newCloudTime":"2020-12-23","czn":true,"fanNum":"eb**776","director":"TAKE-D"},{"id":"b78adf7e4ff8","photo":"http://pics.***.co.jp/digital/video/ebod00682/ebod00682pl.jpg","name":"あすかさん 26歳","lineTime":"2020-05-27","lables":["骨*","巨*","內*","*交","通*"],"score":4.7,"movieType":0,"canLoad":true,"todayNewMovie":false,"newCloudTime":"2020-05-27","czn":true,"fanNum":"eb**682","director":"----"},{"id":"b78adf7e4ff8","photo":"http://pics.d****.co.jp/digital/video/ebod00682/ebod00682pl.jpg","name":" あすかさん 26歳","lineTime":"2020-05-27","lables":["骨*","巨*","內*","*交","通*"],"score":4.7,"movieType":0,"canLoad":true,"todayNewMovie":false,"newCloudTime":"2020-05-27","czn":true,"fanNum":"sti**664","director":"----"}]}';

$jsonStr = json_decode($s, true);
foreach($jsonStr['result'] as $i=>$item) {
  $n = $i + 1;
  $content .='"'.$item['fanNum'].'",';
}
$trimmed  =  rtrim ( $content ,  "," );
echo $trimmed;
?>
Last modification:January 18th, 2021 at 08:35 am
If you think my article is useful to you, please feel free to appreciate