Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. $url = 'http://hebbohotel.com.br/swf/gordon/RELEASE-HEBBO/effectmap.xml';
  3.  
  4. $ch = curl_init();
  5.  
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. curl_setopt($ch, CURLOPT_HEADER, 0);
  8. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); //Transferencia binaria
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Força retornar transferência na variavel
  10.  
  11. $xml = gzdecode(curl_exec($ch));
  12.  
  13. curl_close($ch);
  14.  
  15. $dom = new DOMDocument;
  16. $dom->loadXML($xml);
  17. $effects = iterator_to_array($dom->getElementsByTagName('effect'));//Passa para array
  18.  
  19. //-3 no segundo parametro pega os 3 ultimos itens
  20. $effects = array_slice($effects, -3);
  21.  
  22. foreach ($effects as $effect) {
  23. echo $effect->getAttribute('id'), PHP_EOL;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement