Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think this code can help you:</p> <pre><code>&lt;?php // Your XML string $xmlStr = '&lt;polygon id="svg_806" fill-rule="nonzero" fill="black" stroke-linejoin="round" stroke-width="0" points="94.08955764770508,275.3258819580078 99.92155838012695,275.3258819580078 99.92155838012695,281.16587829589844 94.08955764770508,281.16587829589844 "/&gt;'; // Read the XML into and PHP object, making it ease to access structerd data $xml = new SimpleXMLElement($xmlStr); // Extracts the string inside "points" parameter in polygon (main) tag $pointsStr = (string)$xml-&gt;attributes()-&gt;points; // Breaks the string in pieces of space separated points, like "94.08955764770508,275.3258819580078" $pointsArr = explode(' ', trim($pointsStr)); // The result array, each element is a point (an array with 2 positions) $points = array(); foreach ($pointsArr as $pointStr) { // Reads the float data for each position using C-like sscanf list($x, $y) = sscanf($pointStr, '%f,%f'); // Echo and save echo "Read point ($x, $y)&lt;br&gt;\n"; $points[] = array($x, $y); } ?&gt; </code></pre> <p>It echoes:</p> <blockquote> <p>Read point (94.089557647705, 275.32588195801)<br> Read point (99.921558380127, 275.32588195801)<br> Read point (99.921558380127, 281.1658782959)<br> Read point (94.089557647705, 281.1658782959) </p> </blockquote> <p><code>$points</code> will be:</p> <pre><code>array(4) { [0]=&gt; array(2) { [0]=&gt; float(94.089557647705) [1]=&gt; float(275.32588195801) } [1]=&gt; array(2) { [0]=&gt; float(99.921558380127) [1]=&gt; float(275.32588195801) } [2]=&gt; array(2) { [0]=&gt; float(99.921558380127) [1]=&gt; float(281.1658782959) } [3]=&gt; array(2) { [0]=&gt; float(94.089557647705) [1]=&gt; float(281.1658782959) } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload