我有這個功能顯示標籤列表:PHP注意:數組字符串轉換在數組列表
$DB_QUERY = Access::FETCH("SELECT name, " . NEWS_TAGS . ".id,tags_id,content_id FROM " . NEWS_TAGS . " JOIN " . NEWS_POSTS_TAGS . " ON
" . NEWS_TAGS . ".id = " . NEWS_POSTS_TAGS . ".tags_id WHERE " . NEWS_POSTS_TAGS . ".content_id = ? AND " . NEWS_TAGS . ".type = ? ORDER BY " . NEWS_TAGS . ".name ASC LIMIT 8 ", filter_var($id, FILTER_VALIDATE_INT) , $type);
$ret = array();
foreach($DB_QUERY as $row)
{
$ret[] = $row['name'];
}
$tags = '<li class="label"><a href="#"><i class="fa fa-tag"></i>' . $ret . '</a></li>';
echo $tags;
但我看到這個錯誤:
聲明:Array對C字符串轉換: \ XAMPP \ htdocs中\ frontcms \上線類\的functions.php 449
編輯:
我打印結果print_r($DB_QUERY)
使用PHP print_r
:
Array(
[0] => Array(
[name] => 321[id] => 393[tags_id] => 393[content_id] => 244
) [1] => Array(
[name] => tagname1[id] => 395[tags_id] => 395[content_id] => 244
) [2] => Array(
[name] => tagname2[id] => 394[tags_id] => 394[content_id] => 244
) [3] => Array(
[name] => tagname3[id] => 396[tags_id] => 396[content_id] => 244
)
)
如何解決這一問題?!
這僅僅意味着$標籤是一個數組,所以你可以不回它 – Hearner