Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

【重编】php输出JSON多层嵌套的问题

重新编辑问题:


$ch= '
    [{
        "school": "A校",
        "g": "一年级",
        "c": "一班",
        "n": [
            "男#25",
            "女#29"
        ]
    },
    {
        "school": "A校",
        "g": "一年级",
        "c": "二班",
        "n": [
            "男#30",
            "女#22"
        ]
    
    }]
    '
$chcd= json_decode($ch, true);

for($i=0;$i<count($chcd);$i++){
    echo "".$chcd[$i]['type']."<br /><h1>".$chcd[$i]['school']."&nbsp;&nbsp;".$chcd[$i]['c']."&nbsp;&nbsp;".$chcd[$i]['yy']."</h1>";
 
 echo $chcd->def[$i]->cx; 
 echo "<br /><br />";}

PHP循环输出:

<h1>学校</h1><h2>年级</h2><h3>班级</h3>
<div>
<ul>
<li><u>性别</u>:人数</li>
<li><u>性别</u>:人数</li>
<!--以上"li"循环输出-->
</ul>
</div>

不能循环输出“性别”和“人数”,请求指导!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...