php - How to find specific query in the URL and display whole link -


current code :

include 'simple_html_dom.php';     // create dom url or file     $html = file_get_html('http://www.anylinkalsocan.com');       // find links      foreach($html->find('a') $element)              echo $element->href . '<br>'; 

it crawl , find tag :

<a href="http://news.example.com/node"> 

and output link found on website.

example

http://news.example.com.my/node/321072 http://news.example.com.my/taxonomy/term/2 http://news.example.com.my/node/321060?tid=2 

i want search url contain ?tid= can see on 3rd url in example.

http://news.example.com.my/node/321060?tid=2 

i replace echo $element->href="*?tid return error. can me this?

you can use preg_match or can check urls taken if contain ?tid

<?php include 'simple_html_dom.php'; // create dom url or file $html = file_get_html('http://www.anylinkalsocan.com');   // find links  foreach($html->find('a') $element) {        $search = '?tid';        if(strpos($element->href,$search)) {            echo $element->href . '<br>';        } } ?> 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -