[英]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.