If you can print an ID for each of these Divs, you could try something like this:
function explodeAttributes($string) {
return explode(':', $string);
}
$domDoc = new DOMDocument();
$html_string = '<div id="div1" style="top: 275px; left: 563px;"></div>';
//methods to load HTML
$domDoc->loadHTML($html_string);
$documentElement = $domDoc->getElementById('div1')->getAttribute('style'); // pega o atributo style
$documentElement = explode(';',$documentElement); // converte os atributos para um array
$documentElement = array_filter($documentElement); // remove os itens vazios do array
$documentElement = array_map("explodeAttributes", $documentElement); // converte as propriedades do CSS para array
echo "<pre>" ;
print_r($documentElement);
The result would be something like
Array
(
[0] => Array
(
[0] => top
[1] => 275px
)
[1] => Array
(
[0] => left
[1] => 563px
)
)
Online Test:
http://sandbox.onlinephpfunctions.com/code/f4f9b95a254ee0546c6a4a152ed0f5d9ac729fc8
I removed the CSS tag because, in my view, the issue is not exactly related to CSS.
– Sam
How dynamically these attributes are generated?
– Woss
Hey Sam, good morning Master. You want to recover in render time / in form submission or through action type one click on button?
– Leonardo Getulio
These Divs are generated every time the user clicks on an image on the screen, these Divs are generated with the inline CSS attributes "top" and "left" referring to the click position.
– igorarmelin