I have:
$body = '
<div id="one">
<div id="two">
<div class="sub">
<span class="text"><a class="here" href="/aaa.php">ttt</a></span>
</div>
<span class="f">aa</span>
<div class="sub2">
<a class="here" href="/bbb.php">ttt</a>
<div>
<a class="here" href="/ttt.php">ttt</a>
</div>
<a class="here" href="/ddd.php">ttt</a>
</div>
<div class="sub">
<a class="here" href="/zzz.php">ttt</a>
</div>
</div>
</div>
';
How can i get from this all href from tag "a" to the array? I would like receive:
Array
(
[0] => /aaa.php
[1] => /bbb.php
[2] => /ttt.php
[3] => /ddd.php
[4] => /zzz.php
)
AND NEXT i would like change attribute url to "/test-aaa.php-123", "/test-bbb.php-123" etc in variable $body. So i would like receive:
$body = '
<div id="one">
<div id="two">
<div class="sub">
<span class="text"><a class="here" href="/test-aaa.php-123">ttt</a></span>
</div>
<span class="f">aa</span>
<div class="sub2">
<a class="here" href="/test-bbb.php-123">ttt</a>
<div>
<a class="here" href="/test-ttt.php-123">ttt</a>
</div>
<a class="here" href="/test-ddd.php-123">ttt</a>
</div>
<div class="sub">
<a class="here" href="/test-zzz.php-123">ttt</a>
</div>
</div>
</div>
';
I can make this in javascript, but i must use for this PHP. Is possible?