这是我的代码php5.6
$lang = array(
"HTML" => "60%",
"CSS" => "80%",
"JS" => "70%",
"PHP" => "50%",
);
echo "<ul>";
for ($lang=0; $lang < count($lang) ; $lang++) {
echo "<li>" . $lang[$lang] . "</li>";
}
echo "</ul>";
当我运行我的页面时,它什么也没显示
答案 0 :(得分:0)
在数组上使用foreach。
$langs = array(
'HTML'=> '60%',
'CSS' => '80%',
'JS' => '70%',
'PHP' => '50%',
);
echo '<ul>';
foreach ($langs as $lang=>$per) {
echo "<li>$lang $per</li>";
}
echo '</ul>';