drux41001 2013-07-21 22:35
浏览 120
已采纳

消息数组到字符串转换

That might be a fool question, but I need to know how to solve this: Notice: Array to string conversion in C:\xampp\htdocs\search_view.php on line 248 Why am I getting this message, what can I do to solve it?

echo'<div id="thumb"> 

'.$ids = array();
$ids[] = $results['idGames'];  
for ($i = 0; $i < count($ids); $i++) {

$id = $ids[$i];




$v  = $results['total_votes'];
$tv = $results['total_value'];
if ($v)
    $rat = $tv / $v;
else
    $rat = 0;



$j  = $ids[$i];
$id = $ids[$i];
echo '<div class="topcontentstar">

    <div id="' . $id . '" class="">';
for ($k = 1; $k < 6; $k++) {
 if ($rat + 1 > $k)
    $class = "" . $k . "  ratings_stars_index ratings_vote";
    else
    $class = "" . $k . " ratings_stars_index ratings_blank";
     echo '<div class="' . $class . '"></div>';
}
echo ' 
</div>
    </div></div>;
  • 写回答

4条回答 默认 最新

  • doupang1917 2013-07-21 22:41
    关注

    You're doing this:

    echo'<div id="thumb"> 
    (line 248) '.$ids = array();
    

    Basically, you can't concatenate array with a string and that's why the error appears.

    To fix the error, you can separate the array declaration into a separate line:

    echo'<div id="thumb">';
    $ids = array();
    

    Hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死