1
iyear 2020-08-16 15:18:57 +08:00 via Android
这源文件不就是个 json 么。。难道我看错了吗
|
3
baoshuo 2020-08-16 15:32:30 +08:00 1
```php
<?php $data = json_decode(file_get_contents("http://push2.eastmoney.com/api/qt/kamt.rtmin/get?fields1=f1&fields2=f51,f56")); $data = $data->data->s2n; echo "[\n"; for($i = 0 ; $i < sizeof($data)-1 ; $i++) { echo " {\"time\": \"".explode(',', $data[$i])[0]."\", \"price\": ".explode(',', $data[$i])[1]."\"},\n"; } echo " {\"time\": \"".explode(',', $data[sizeof($data)-1])[0]."\", \"price\": ".explode(',', $data[sizeof($data)-1])[1]."\"}\n"; echo "]\n"; ?> ``` php 新手,代码烂,请见谅 |
4
malagebidi OP @baoshuo 谢谢,问题解决了 v👍😉
|
6
malagebidi OP @em70 手动格式化太闹心了,还是得代码自动化来解决。
|