3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = 'Dit is een link: <a href="bla.html">Tralalala</a>, en nog eentje: <a href="bla.html">Tralalala</a>'; $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; preg_match_all("/$regexp/siU", $string, $matches); // $matches[2] = array of link addresses // $matches[3] = array of link text - including HTML code echo "test"; print_r($matches); ?>
Output for 4.3.0 - 7.2.0
testArray ( [0] => Array ( [0] => <a href="bla.html">Tralalala</a> [1] => <a href="bla.html">Tralalala</a> ) [1] => Array ( [0] => " [1] => " ) [2] => Array ( [0] => bla.html [1] => bla.html ) [3] => Array ( [0] => Tralalala [1] => Tralalala ) )