Today, due to work requirements, I need to obtain the attribute value of the html tag, and I immediately thought of regular expressions , the tags are as follows:
< ;circle id="ap_test" cx="201" cy="2001" r="2" stroke="black" stroke-width="0" fill="red"/>
I need to get the cx and cy attribute values of the
$circle is the content of the circle tag above
preg_match_all('/]*?cxs*=s*('|")(.*?)\1[^>]*?cys*=s *('|")(.*?)\1[^>]*?/?s*>/i', $circle, $arr);
var_dump($arr);
$arr[2] is the value of cx, $arr[4] is the value of cy.
<span id="line25"><span id="line26"><span id="line27"><span id="line28"><span id="line29"><span id="line30"><span id="line31"><span id="line32"><span id="line33"><span id="line34"><br /><br /></span></span></span></span></span></span></span></span></span></span>