Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/06/2014, 13:04
joanmigo
 
Fecha de Ingreso: junio-2014
Mensajes: 10
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: preg_match() y £ Libra Esterlina

He puesto ese codigo anteriormente y nada :(
mejor le muestro todo mi codigo:

Código PHP:
Ver original
  1. <div align="center">
  2.  
  3. <?php
  4. header('Content-Type: text/html; charset=iso-8859-1');
  5.  
  6. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Sash%20of%20the%20Third%20Insight");
  7. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Talon%20of%20the%20Scarlet%20Raven");
  8. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Dragonclaw%20Hook?filter=MEATHOOK");
  9. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Sash%20of%20the%20Ravager");
  10. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Arms%20of%20the%20Cryogenic%20Embrace");
  11. //$data = file_get_contents("http://steamcommunity.com/market/listings/570/Heroic%20Hood%20of%20the%20Scarlet%20Raven");
  12. $data = file_get_contents("http://steamcommunity.com/market/listings/570/Inscribed%20Wraps%20of%20the%20Drunken%20Warlord");
  13.  
  14.  
  15. if ( preg_match_all('/(?:th_fee\">)\s*(.+)\s*(?:<\/span>)/' , $data , $cap, PREG_PATTERN_ORDER ) )
  16. {
  17.     $i=0;
  18.     while ($i < 7){
  19.         if($i>=0){     
  20.                 //echo "num:".strlen(trim($cap[1][$i]))."<-<br>";
  21.                 //echo "res1:".trim($cap[0][$i])."<-<br>";
  22.                 //echo "res2:".trim($cap[1][$i])."<-<br>";
  23.                 $cap[0][$i]=trim($cap[0][$i]);
  24.                 $cap[1][$i]=trim($cap[1][$i]);
  25.             //  if(isset($cap[0][$i])){ echo "&nbsp;P".$i.": ".trim($cap[0][$i])."   --- T:".strlen(trim($cap[1][$i]))." <br>";}else{ echo "&nbsp;P".$i.": S/P<br>"; }
  26.                 if(isset($cap[1][$i])){ echo "&nbsp;P".$i.": ".trim($cap[1][$i])."   --- T:".strlen(trim($cap[1][$i]))." <br>";}else{ echo "&nbsp;P".$i.": S/P<br>"; }
  27.         }
  28.     $i++;
  29.     }
  30.    
  31.     echo "<br>-------------------------------------------------------------------------------------------------<br>";
  32.     $b=0;
  33.     while ($b < 7){
  34.         if($b>=0){     
  35.                 echo "<br>";
  36.                 $p1=$cap[1][$b];
  37.                 for($i=0;$i<strlen($p1);$i++){
  38.                     echo ord(substr($p1,$i,1))."-";
  39.                 }
  40.                 echo "<br>";
  41.                 for($i=0;$i<strlen($p1);$i++){
  42.                     echo chr(ord(substr($p1,$i,1)))."-";
  43.                 }
  44.         }
  45.     $b++;
  46.     }
  47.  
  48.     echo "<br>-------------------------------------------------------------------------------------------------<br>";
  49.    
  50.     $i=0;
  51.     while ($i < 7){
  52.         if($i>=0){ 
  53.             if(isset($cap[1][$i])){
  54.                 echo $i;
  55.                
  56.                 //Verificando si es dolar
  57.                 if(preg_match("/$/", $cap[1][$i])>0){
  58.                     if(preg_match_all('/([0-9]+).([0-9]+) /',$cap[1][$i],$dol)){
  59.                     echo "&nbsp;Dolares: ".$dol[0][0]."<br>";
  60.                     }else{
  61.                         if(preg_match_all('/([0-9]+) /',$cap[1][$i],$dol)){
  62.                         echo "&nbsp;Dolares: ".$dol[0][0]."<br>";
  63.                         }
  64.                     }
  65.                 }
  66.                
  67.                 //Verificando si es Rublo
  68.                 if(preg_match("/б/", $cap[1][$i])>0){
  69.                     if(preg_match_all('/([0-9]+),([0-9]+) /',$cap[1][$i],$rub)){
  70.                         echo "&nbsp;Rublos: ".str_replace(",", ".", $rub[0][0])."<br>";
  71.                     }else{
  72.                         if(preg_match_all('/([0-9]+) /',$cap[1][$i],$rub)){
  73.                         echo "&nbsp;Rublos: ".$rub[0][0]."<br>";
  74.                         }
  75.                     }
  76.                 }
  77.  
  78.                 //Verificando si es Euro
  79.                 if(preg_match("/€/", $cap[1][$i])>0){
  80.                     if(preg_match_all('/([0-9]+),([0-9]+)/',$cap[1][$i],$eu)){
  81.                     echo "&nbsp;Euro: ".str_replace(",", ".", $eu[0][0]) ."<br>";
  82.                     }else{
  83.                         if(preg_match_all('/([0-9]+) /',$cap[1][$i],$eu)){
  84.                         echo "&nbsp;Euro: ".$eu[0][0]."<br>";
  85.                         }
  86.                     }
  87.                 }          
  88.                
  89.                 //Verificando si es RealBrasileño
  90.                 if(preg_match("/R$/", $cap[1][$i])>0){
  91.                     if(preg_match_all('/([0-9]+),([0-9]+)/',$cap[1][$i],$rs)){
  92.                     echo "&nbsp;Real Brasileño: ".str_replace(",", ".", $rs[0][0]) ."<br>";
  93.                     }else{
  94.                         if(preg_match_all('/([0-9]+) /',$cap[1][$i],$rs)){
  95.                         echo "&nbsp;Real Brasileño: ".$rs[0][0]."<br>";
  96.                         }
  97.                     }
  98.                 }
  99.                
  100.                 //Verificando si es Libra esterlina
  101.                 //if(preg_match("/^œ/", $cap[1][$i])>0){
  102.                 if (preg_match_all('/£([0-9.]{1,10})/', $cap[1][$i],$le)){
  103.                 //if(preg_match('/£/', $cap[1][$i])>0){
  104.                     if(preg_match_all('/([0-9]+),([0-9]+)/',$cap[1][$i],$le)){
  105.                     echo "&nbsp;Libra: ".str_replace(",", ".", $le[0][0]) ."<br>";
  106.                     }else{
  107.                         if(preg_match_all('/([0-9]+) /',$cap[1][$i],$le)){
  108.                         echo "&nbsp;Libra: ".$lem[0][0]."<br>";
  109.                         }
  110.                     }
  111.                 }
  112.                
  113.                 $i++;
  114.             }
  115.         }
  116.     }
  117. }
  118.  
  119. ?>
  120. </div>

La respuesta de este codigo es el siguiente:




Gracias de antemano