PHP返回单词数组
我有以下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)
$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)