[英]I got Error Notice: Array to string conversion in my code php
hi guys i got problem in my code i don't know where come form this my code 嗨,大家好,我的代码有问题,我不知道我的代码从哪里来
<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 } ?>
And the error message, 和错误消息,
and Iam sure all code are same i don't what's problem !! 而且我敢肯定,所有代码都是一样的,我没有什么问题!
You are trying to echo an array variable which is not right. 您正在尝试回显不正确的数组变量。 Use the below debug code and you have to parse the array however you want. 使用下面的调试代码,您必须根据需要解析该数组。
Authors -> <?php echo "<pre>";print_r($item["authors"]);echo "<pre>"; ?>
my problem is solved 我的问题解决了
by replace 通过替换
<td><?php echo $item["authors"]; ?></td>
to 至
<td><?php echo implode(",", $item["authors"]); ?></td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.