There is a string
<div class="value1 666"></div> How to use PHP and Regex to get an array of two values value1 and 666 ?
My current solution is:
$regex = "/(?:.*class[ ]*=[ ]*[\"\'])(.*)(?:[\"\'].*)/"; $html = "<div class='value1 666'></div>"; preg_match_all($regex, $html, $results); var_dump($results); It has the following disadvantages:
- in the
$resultsarray, the first value is always the input string - only works if the attribute is set to one value