I need to get an array of nicknames. The fact is that all the data is displayed perfectly, but when a string is divided into an array $vivod = preg_split("/[?[][\w]{1,2}]/", $vivod); it turns out the nonsense just goes instead of each array array, I need to transfer this list to an array for further grabbing for each of them ... something like $length = count($vivod); for ($i = 0; $i < $length; $i++) { $length = count($vivod); for ($i = 0; $i < $length; $i++) { how to do it correctly that not everything in the line would go like it gives me, but each separately ...

 <?php require_once 'simple_html_dom.php'; $data = file_get_html('http://w2.dwar.ru/instance_stat.php?outside=1&instance_id=131374891&finish=0'); if($data->innertext!='' and count($data->find('a'))){ foreach($data->find('a') as $a){ $vivod = $a->plaintext; $vivod = $vivod . ''; echo $vivod[1] . ''; } } ?> 

With normal grabbing, the list goes to one-line nicknames ... like this

 <?php require_once 'simple_html_dom.php'; $data = file_get_html('http://w2.dwar.ru/instance_stat.php?outside=1&instance_id=131374891&finish=0'); if($data->innertext!='' and count($data->find('a'))){ foreach($data->find('a') as $a){ $vivod = $a->plaintext; $vivod = $vivod . ''; echo $vivod . ''; } } ?> 

Is it possible to simplify such a grabbing? What would be faster or load well, or at least the place did not take so much?

 // КЛАН $clan = file_get_contents($url); if (strpos($clan, 'images/data/clans/')){ $pos = strpos($clan, 'images/data/clans/'); $clan = substr($clan, $pos); $pos = strpos($clan, '.gif" width="13" height="13" border="0" alt="" align="absmiddle">'); $clan = substr($clan, 0, $pos); $clan = str_replace('images/data/clans/','', $clan); $sclan = $clan; } else { $sclan = ''; } /* Выполняем запрос. Если нез клана не выводить его. */ if ($sclan) { $clanicus = '<img src="http://w2.dwar.ru/images/data/clans/'.$sclan.'.gif" border="0" alt="" />'; } else { $clanicus = ''; } 
  • There is a page that you are trying to grab from it? Formulate the question correctly. ps good evening: D - Invision
  • Good evening ...)) I get a response from the grabber in the following way -CroCop- [4]dok3 (ФЭО-Прайм) [4]Бубльдубль (ФЭО-Прайм) [4] trying to grab the nicknames ... in the array that everyone was separately ... from each other) - Constantine
  • But if you add print $vivod.'<br />'; then instead of one '<br />' somewhere two or three comes out, and when closing the bracket } nothing is left ... - Constantine

1 answer 1

The decision to obtain nicknames

 <?php $content = file_get_contents('http://w2.dwar.ru/instance_stat.php?outside=1&instance_id=131374891&finish=0'); preg_match_all("'userToTag\(\'(.*?)\'\);'si", $content, $match); print_r($match[1]); 

Result

 Array ( [0] => -CroCop- [1] => dok3 (ФЭО-Прайм) [2] => Бубльдубль (ФЭО-Прайм) [3] => _-CeSaR-_ (ФЭО-Прайм) [4] => войпель (ФЭО-Прайм) [5] => hooliganka221 [6] => --_КотоФей_-- [7] => -Horing- (ФЭО-Прайм) [8] => yula2 [9] => koln [10] => Хаватар [11] => Диэль [12] => Перс Персович [13] => OLEGBRAY [14] => _смертник11_ (ФЭО-Прайм) [15] => -Татьяна27- [16] => poayk777 [17] => Alexandr_Victory [18] => Bloodomen ) 
  • Thank you very much)) now I’m torturing the code))) if I hope I can help)) - Konstantin
  • And tell me the data how to transfer now? $length = count($match[1]); for ($i = 0; $i < $length; $i++) { print $match[$i]; } $length = count($match[1]); for ($i = 0; $i < $length; $i++) { print $match[$i]; } so does not work) - Constantine
  • where to send? Just list out? - Invision
  • foreach ($match[1] as $nickname) echo $nickname.'<br>'; - Invision
  • Thanks, but if I specify a variable 1 time ... foreach ($match[1] as $nickname) $url = "http://w2.dwar.ru/user_info.php?nick=".$nickname . $ups; foreach ($match[1] as $nickname) $url = "http://w2.dwar.ru/user_info.php?nick=".$nickname . $ups; after that only 1 last nickname is displayed and that's it .. further I specify echo $nickname.'<br>'; and it turns out just the last Bloodomen - Constantine