關於PHP從資料庫的關鍵詞如何全部輸出?

來源:互聯網
上載者:User
關鍵字 php
====================================
資料庫表是
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 先組裝成你想要的 字串樣式 在輸出

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.