$str=file_get_contents("http://www.heroeswm.ru/clan_info.php?id=41"); preg_match_all('/(Глава: .*?")/', $str, $name); $name = implode("", $name[0]); echo $name; 

This script displays from the page all the information from "Chapter" to "Protocol". I also need to bring only nick Head. That is, so that proparsilos from “Head” and to the end of the nickname of the Head himself. How to fix? I understand that only the line needs to be changed:

 preg_match_all('/(Глава: .*?")/', $str, $name); 
  • Replaced with this code, but nothing appeared. I understand, it creates an array. But how can I get this to the page? if (preg_match_all ('~ <b> (Chapter: </ b> <a class=pi href=\ pl_info.php\?id=\d+\'> (. *?)) </a> ~ u' , $ str, $ name)) {print_r ($ name); } - MediaPortal

1 answer 1

 preg_match_all('~<b>(Глава: </b><a class=pi href=\'pl_info.php?id=\d+\'>.*?)</a>~', $str, $name); 

Yes, my mistake. forgot "?" shield

here is a new version:

 if (preg_match_all('~<b>(Глава: </b><a class=pi href=\'pl_info.php\?id=\d+\'>(.*?))</a>~u', $str, $name)){ print_r($name); } 

will output:

 Array ( [0] => Array ( [0] => <b>Глава: </b><a class=pi href='pl_info.php?id=4598'>Игнациус</a> ) [1] => Array ( [0] => Глава: </b><a class=pi href='pl_info.php?id=4598'>Игнациус ) [2] => Array ( [0] => Игнациус ) ) 
  • Not properly. Nothing derives! - MediaPortal
  • after preg_match_all make var_dump ($ name); what does? - Sh4dow
  • updated answer - Alex Kapustin