Good afternoon, help to pull out the name of the songs from the array of regular.

There is the following code in the array

<div class="content"> <a title="Basslovers United - Drunken (Finger & Kadel Remix)" href="http://mp3-you.ru/listen/online28435.html">Basslovers United - Drunken (Finger &amp; Kadel Remix)</a> </div> <div class="content"> <a title="Basslovers United - Drunken (Finger & Kadel Remix)" href="http://mp3-you.ru/listen/online28435.html">Basslovers United - Drunken (Finger &amp; Kadel Remix)</a> </div> 

That is, the lines are repeated. I only need to pull out the title between <div class="content><a> and </a></div> . I tried this way:

 if ($grab) { $grab=str_replace("<br>","\n",$grab); // Получить регулярным выражением тексты preg_match_all("/<div class=\"content\">([^>]*>){12}([^<]*)/",$grab,$matches); // В массиве содержатся все найденные строки for ($i=0; $i<count($matches[0]); $i++) { echo nl2br($matches[0][$i]); echo '<hr>'; } } 

But in the output I have not only the text, but the links and the divas themselves.

    1 answer 1

    I do not understand why suffer, starting from divs? If you have no other ("left links") in the array, then why not just start looking for a tag a ?

     $grab = '<div class="content"> <a title="Basslovers United - Drunken (Finger & Kadel Remix)" href="http://mp3-you.ru/listen/online28435.html">Basslovers United - Drunken (Finger & Kadel Remix)</a> </div> <div class="content"> <a title="Basslovers United - Drunken (Finger & Kadel Remix)" href="http://mp3-you.ru/listen/online28435.html">Basslovers United - Drunken (Finger & Kadel Remix)</a> </div>'; preg_match_all("#<a[^>]+>(.+?)</a>#i",$grab,$matches); echo "<pre>"; print_r($matches); echo "</pre>";