基于给出的答案对我有用的答案
while($post = mysql_fetch_array($tags)) {
$push = explode(',', $post['tags']);
$array = array_merge($array, $push);
}
所以我试图从我的数据库中显示标签并用它们制作链接,如下所示:
<?
$tags = mysql_query( 'SELECT tags FROM `Table`');
$array = array();
while($post = mysql_fetch_array($tags)) {
$push = explode(',', $post['tags']);
array_push($array, $push);
}
foreach ($array as $value) {?>
<a href="url.php?tags=<? echo $value?>"><? echo $value?></a>
<? }
?>
然而我得到的只是
<a href="url.php?tags=Array">Array</a>
我应该至少有三行,就像以前制作的那样
<?
$tags = mysql_query( 'SELECT tags FROM `Table`');
while($post = mysql_fetch_array($tags)) {
$array = explode(',', $post['tags']);
foreach ($array as $value) {?>
<a href="url.php?tags=<? echo $value?>"><? echo $value?></a>
<? }
}
?>
被调用的代码如下所示:
tag1, tag2, tag3
试过了
while($post = mysql_fetch_array($tags)) {
$push = explode(',', $post['tags']);
array_merge($array, $push);
}
foreach ($array as $value) {?>
<a href="index.php?tags=<? echo $value?>"><? echo $value?></a>
现在 foreach 不返回值