【发布时间】:2016-05-29 02:24:27
【问题描述】:
我不断收到错误消息:解析错误:语法错误,意外的 'sName' (T_STRING),在第 5 行期待 ']' 我需要一些帮助来解决这个问题。谁能告诉我我的代码有什么问题?
<!DOCTYPE html>
<?php
$data = array [
["sName” => “Gervase”, "sNumber" => "s1234567", "mark” => 95, “comments” => “Well done!”],
["sName” => “Matt”, "sNumber" => "s1234567", "mark” => 95, “comments” => “Well done!”],
["sName” => “Kid”, "sNumber" => "s1234567", "mark” => 95, “comments” => “Well done!”],
["sName” => “Nathan”, "sNumber" => "s1234567", "mark” => 85, “comments” => “Well done!”]
]
?>
<html>
<head>
<link type='text/css' rel='stylesheet' href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
</head>
<body>
<div>
<div class="jumbotron">
<div>
<div class="container">
<h1>Data</h1>
</div>
<div>
<div class="container">
<table>
<table class="table">
<thead>
<?php
foreach ($data as $data)
{
echo"<tr>";
echo"<td>".$data["sName"]."</td>";
echo"<td>".$data["sNumber"]."</td>";
echo"</tr>";
}
?>
<tr>
<th>Student number</th>
<th>Student name</th>
<th>Mark</th>
<th>Comments</th>
</tr>
<tr>
<td>Something</td>
</tr>
</thead>
</table>
</div<
</div>
</body>
【问题讨论】:
标签: php html arrays loops foreach