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.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?