【问题标题】:PHP returns the word array [closed]PHP返回单词数组[关闭]
【发布时间】:2013-06-14 09:13:51
【问题描述】:

我有这个 php 代码:

$tunnid = array();
while ($row = mysql_fetch_assoc($result)) {
    $tunnid[] = $row['total'];

  }

$this->set('tunnid', $tunnid);
mysql_free_result($result); 

为了显示它,我有这个:

<?php
if(!empty($tunnid)) {
    foreach($tunnid as $tund) {
echo "$tunnid";

    }

}

由于某种原因,这会返回 ArrayArrayArrayArray

我在这里做错了什么?谢谢

【问题讨论】:

标签: php arrays return


【解决方案1】:

你有一个小错误

<?php
if(!empty($tunnid)) {
     foreach($tunnid as $tund) {
     echo "$tund"; //not tunnid

   }

}

【讨论】:

  • 确实,我太傻了 :) 我会在 12 分钟后将此标记为正确答案,但是,现在它返回 144904782467667666689479742521 等。我如何让它们分开?
  • 需要格式化字符串可以使用printf("%s\n", $tund)
猜你喜欢
  • 1970-01-01
  • 2014-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多