Good day. Not good at regular expressions. Help finish.

This code takes the text from the site, namely the page - http://best-muzon.ru/lastnews/ It is necessary to cut out only the names of the songs, but with my regular season, it displays only part of the songs.

There is a code -

$skrap = parser ($host,$path,$start,$end,$include); if ($skrap) { // Заменить теги переноса строки на простые переносы строки $grab=str_replace("<br>","\n",$grab); // Получить регулярным выражением тексты цитат preg_match_all("/<div id=\"shrt\">([^>]*>){12}([^<]*)/",$skrap,$matches); // В массиве содержатся все найденные строки for ($i=0; $i<count($matches[2]); $i++) { echo '<a href="/mp3/'.nl2br($matches[2][$i]).'">'.nl2br($matches[2][$i]).'</a>'; echo '<br>'; } } 
  • Also, after the withdrawal, writes Array, how to get rid of? - vits
  • Give a piece of text that needs to be parsed and the desired result from this text. - ReinRaus

1 answer 1

You speak only the names, but at the same time you pull the whole link?

We get only the names

 /<div\sid=\"shrt\"><img\s.*?/>\r\n<a\shref=\".*?\"\stitle=\".*?\">(.*?)</a>\r\n</div>/ 

Rude, but try. may need to delete rn. Checked in Notepad ++

About Array, try

 var_dump($var) 

Look at that array.

  • one
    IMHO print_r taxis =) - Zowie
  • Tastes differ. - UndReim
  • Warning: preg_match_all () [function.preg-match-all]: Unknown modifier '>' in D: \ Webwork \ webserver \ domains \ music.os \ www \ index.php on line 442 This error happens with your example - vits
  • > need to screen. - ReinRaus
  • How to screen, as I understand it in quotes, but another error appears - vits