0
我得到一個錯誤,說第二個foreach循環第24行提供了無效參數。你能看到這個錯誤嗎?它最初必須將聯繫人顯示在html中的表格中。任何洞察力將非常感激。讀取文件並寫入html表格
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="styles/session_Style.css">
<title>User Session</title>
</head>
<body>
<div class="container">
<div id="table">
<?php
$filename = "Contacts.txt";
$content = file_get_contents($filename);
$formContacts = explode('|----------|', $content);
foreach ($formContacts as $formContact => $contact) {
echo '<table>';
echo '<tr><th colspan="2">Contact '.$formContact.'</th></tr>';
foreach ($contact as $detail) {
$details = explode(':',$detail);
echo '<tr><td>'.$details[0].'</td><td>'.$details[1].'</td></tr>';
}
echo '</table>';
}
?>
</div>
<div class="logout">
<h1>User Details</h1>
<form method="post" action="">
<p class="submit"><input type="submit" name="commit" value="Log Out" onclick="document.location.href='home-page.html';"></p>
</form>
</div>
</div>
</body>
</html>
Contacts.txt的結構是這樣
First Name : ......;
Last Name: ......;
Contact Details:.....;
Email Address:.....;
Enquirer Type:.....;
Contact Method:....;
Message:....';
|----------|
First Name : ......;
..............
您的代碼完美的作品。只是困擾我的佈局。 http://s31.postimg.org/mjn05701n/jpeg.jpg這是輸出。 AS聯繫人0名字在第1行第1行中,第2行第1行中的其餘部分的詳細名稱。是否有方法在彼此之間顯示名字,姓氏等等? –
Contacts.txt的全部內容如何? –
我的例子[截圖](http://postimg.org/image/ysatxxwxj/) –