there is such a line

var_dump($string) string(125) "<div style="position: relative"><a href="/lists/m_act%5Bcountry%5D/1/">США</a></div>" 

I'm trying to exclude <div style="position: relative"><a href="/lists/m_act%5Bcountry%5D/1/"></a></div> while only taking the first part like this

 $regOne='/<div (.*)="(.*)"><a href="(.*)/\d/">/'; $repl=""; var_dump(preg_split($regOne,$repl,(string)$string)); 

I get the preg_split () expects parameter 3 to be long, string given

2 answers 2

Exclude - just throw out as unnecessary? There is a native strip_tags function

If you need to get data from a regular program, use preg_match or preg_match_all

  • Aha here is the html line, what is the regular schedule for you here, build the dom tree and get everything you need ... - Naumov
 $html = '<div style="position: relative"><a href="/lists/m_act%5Bcountry%5D/1/">США</a></div>'; $htmlDOM = new DOMDocument(); $htmlDOM->loadHTML($html); $xpath = new DOMXPath($htmlDOM); echo $val = $xpath->query('//div/a')->item(0)->nodeValue;