PHP返回单词数组

时间:2013-06-14 09:13:52

标签: php arrays return

我有这个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

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

1 个答案:

答案 0 :(得分:4)

你有一点错字

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

   }

}