dtp19819 2018-07-24 07:50
浏览 75

PHP:如何只从变量中获取文本?

how can i get only text data from the table? Without any links and images?

    while ($row = $most_rep->fetch_assoc()) {
    $post_title = $row['post_title'];
    $post_content = mb_substr($row['post_content'],0,120);
    $guid = $row['guid'];
    $post_date = $row['post_date'];
    echo 
    "<a href='$guid' target='_blank'>"
    ."<div class='post_title'>$post_title</div>"."</a>"
    ."<a href='$guid' target='_blank'>"
    ."<div class='post_description'>$post_content</div>"
    ."<div class='post_date'>$post_date</div>"
    ."</a>";
}

Inside variable $post_content i have text and images and links from the post. I would like to echo only text.

Appreciate any help

  • 写回答

4条回答

  • dongmiyi8220 2018-07-24 07:56
    关注

    it is not the best practice but if you still insist using this kind of approach i suggest add some Delimiter to your data $row['post_content'] and use explode(" ",$row['post_content']) to get the specific text or value that you want.

    Note: the explode function will return an array.

    评论

报告相同问题?