[英]I got Error Notice: Array to string conversion in my code php
嗨,大家好,我的代碼有問題,我不知道我的代碼從哪里來
<h1><?php echo $item["title"]; ?> </h1>
<table>
<tr>
<th>Catageory</th>
<td><?php echo $item["category"]; ?></td>
</tr>
<tr>
<th>Genre</th>
<td><?php echo $item["genre"]; ?></td>
</tr>
<tr>
<th>Format</th>
<td><?php echo $item["format"]; ?></td>
</tr>
<tr>
<th>Year</th>
<td><?php echo $item["year"]; ?></td>
</tr>
<?php
if(strtolower($item["category"]) == "books"){
?>
<tr>
<th>Authors</th>
<td><?php echo $item["authors"]; ?></td>
</tr>
<tr>
<th>Publisher</th>
<td><?php echo $item["publisher"]; ?></td>
</tr>
<tr>
<th>ISBN</th>
<td><?php echo $item["isbn"]; ?></td>
</tr>
<?php } ?>
和錯誤消息,
而且我敢肯定,所有代碼都是一樣的,我沒有什么問題!
您正在嘗試回顯不正確的數組變量。 使用下面的調試代碼,您必須根據需要解析該數組。
Authors -> <?php echo "<pre>";print_r($item["authors"]);echo "<pre>"; ?>
我的問題解決了
通過替換
<td><?php echo $item["authors"]; ?></td>
至
<td><?php echo implode(",", $item["authors"]); ?></td>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.