Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP返回单词数组_Php_Arrays_Return - Fatal编程技术网

PHP返回单词数组

PHP返回单词数组,php,arrays,return,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)

我有以下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";

    }

}
你有点打字错误

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

   }

}

您正在将数组强制转换为字符串。也请看,我真是太蠢了:)我会在12分钟后将此标记为正确答案,但是,现在它返回1449047824676676689479742521等。如何将它们分开?需要格式化字符串,您可以使用
printf(“%s\n”,$tund)