Php string如果包含echo那个字符串

时间:2015-05-22 14:42:19

标签: php string

My Php mysql out put是我需要的数组,如果字符串包含特定字符,我只需要打印该字符串

while($row2 = mysqli_fetch_array($result2)) { 
 echo $row2['link'];
} 

Output is:
http://www.videoweed.es/file/b38300afda3e6
http://www.novamov.com/video/303a4428f6c6a
http://www.movshare.net/video/081aaa1356a6b

我需要这样

 if (strpos($a,'videoweed') !== false) {
 echo $row2['link'];
  }

它显示出来的是:

 http://www.videoweed.es/file/b38300afda3e6
http://www.novamov.com/video/303a4428f6c6a
http://www.movshare.net/video/081aaa1356a6b

我只需要输出;

 http://www.videoweed.es/file/b38300afda3e6

1 个答案:

答案 0 :(得分:1)

您已在代码中回答。只需要组装它。检查一下: -

while($row2 = mysqli_fetch_array($result2)) { 
  if (strpos($row2['link'],'videoweed') !== false) {

  echo $row2['link'];
  }

}