Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. $url = 'http://www.webservicex.net/airport.asmx/GetAirportInformationByCountry';
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, $url);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  6. curl_setopt($ch, CURLOPT_POST, 1);
  7. curl_setopt($ch, CURLOPT_POSTFIELDS, 'country=paramAero');
  8. curl_setopt($ch, CURLOPT_HEADER, 0);
  9. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  10. $result = curl_exec($ch);
  11. $err = curl_error($ch);
  12. curl_close($ch);
  13.  
  14. $result = substr($result, 114);
  15. $result = substr($result,0,- 30);
  16. $result = chop($result);
  17. $borra = array("Table","CityOrAirportName","<",">","/");
  18. $output = str_replace($borra, '',$result);
  19. $output = explode(PHP_EOL, $output);
  20.  
  21. $xml = simplexml_load_string($xml);
  22.  
  23.  
  24. $i=0;
  25. $aero = array();
  26. foreach ($output as $value) {
  27. if(strlen($value)>3){
  28. $aero[++$i] = $value;
  29. }
  30. }
  31. echo '<select id="campoAeropuerto" name="campoAeropuerto">';
  32.  
  33. foreach($aero as $key => $value){
  34. echo '<option value="'.$key.'">'.$value.'</option>';
  35. }
  36. echo '</select>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement