<?php
$content= file_get_contents('获取json字符串的url')
$content = json_decode($content)//将json字符串转化成php数组
foreach ($content as $key ) {//循环数组
echo '<li>' . $key['city'] . '</li>'
echo '<li>' . $key['city_en'] . '</li>'
echo '<li>' . $key['date_y'] . '</li>'
echo '<li>' . $key['week'] . '</li>'
}
用json_decode()将json字符串转化成php数组,然后直接循环数组取出值即可。<?php
$content= file_get_contents('获取json字符串的url')
$content = json_decode($content)//将json字符串转化成php数组
foreach ($content as $key ) {//循环数组
echo '<li>' . $key['city'] . '</li>'
echo '<li>' . $key['city_en'] . '</li>'
echo '<li>' . $key['date_y'] . '</li>'
echo '<li>' . $key['week'] . '</li>'
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)