====================================
資料庫表是
id keywords
1 你好,很好,都好
1 都很好
1 很好,行
$str = $row['keywords'];
列印後是:
string(20) "你好,很好,都好"
string(26) "都很好"
string(34) "很好,行"
我想輸入來的一些詞,把他們分開加上連結。
以下代碼是 phpwind架構,直接迴圈輸出了。
$dosql->Execute("SELECT * FROM
#@__infolist` WHERE (classid=1 ) ORDER BY id ASC LIMIT 0,100");
{ while ($row = $dosql->GetArray()) echo $str = $row['keywords']; //這裡 輸出是 你好,很好,都好,都很好,很好,行 $str_keywords= array_filter(explode(",",$str)); //目的是為了把逗號替換掉}foreach($str_keywords as $v){ echo ''.$v.''; //結果這裡只輸出 很好 行 }`
為什麼不全部輸出呢? 只有很好 行
是用phpmywind架構。
回複內容:
====================================
資料庫表是
id keywords
1 你好,很好,都好
1 都很好
1 很好,行
$str = $row['keywords'];
列印後是:
string(20) "你好,很好,都好"
string(26) "都很好"
string(34) "很好,行"
我想輸入來的一些詞,把他們分開加上連結。
以下代碼是 phpwind架構,直接迴圈輸出了。
$dosql->Execute("SELECT * FROM
#@__infolist` WHERE (classid=1 ) ORDER BY id ASC LIMIT 0,100");
{ while ($row = $dosql->GetArray()) echo $str = $row['keywords']; //這裡 輸出是 你好,很好,都好,都很好,很好,行 $str_keywords= array_filter(explode(",",$str)); //目的是為了把逗號替換掉}foreach($str_keywords as $v){ echo ''.$v.''; //結果這裡只輸出 很好 行 }`
為什麼不全部輸出呢? 只有很好 行
是用phpmywind架構。
$str_keywords 覆蓋了之前的 $str_keywords值。。。修改為 $str_keywords= array_merge($str_keywords, array_filter(explode(",",$str)));
你把keywords 先組裝成你想要的 字串樣式 在輸出