Ver Mensaje Individual
  #5 (permalink)  
Antiguo 30/07/2012, 15:18
wendyl
 
Fecha de Ingreso: marzo-2012
Ubicación: Bogota
Mensajes: 177
Antigüedad: 12 años, 1 mes
Puntos: 2
Respuesta: recoger datos de un txt

Cita:
Iniciado por webankenovi Ver Mensaje
str_replace y eliminas las letras y los caracteres que desees

http://es.php.net/manual/es/function.str-replace.php
Código PHP:
<?php
    
include("conexion.php");
$link=conexion();
$gestor = @fopen("REPORTES/Reporte_Ultimos7_dias.txt""r");//tarificacion04202012.txt
if ($gestor) {
$i=
$cod=0;
    echo 
"<table border='1' align='center'>";
    echo 
"<tr>";
    echo 
"<td>cod</td><td>Date</td><td>Time</td><td>Sec_dur</td><td>Cond_code</td><td>Calling_num</td><td>Dialed_num</td><td>Auth_code</td><td>in_trk_code</td><td>in_crt_id</td><td>Code_used</td><td>Out_crt_id</td><td>Out_crt</td>";
    echo 
"</tr>";
//pag 70 http://www.edwardybella.com/archivos/crepusculo.pdf
//http://www.cs101-class.org/#
    
while (($buffer fgets($gestor999)) !== false) {
    
//$resultado=preg_split('/[A-z|;]/', $buffer[1]);
   // if (($i % 2) != 0) {    
    
$Date=substr($buffer0,7);
    
$Time=substr($buffer,  11,5);
    
$Sec_dur=substr($buffer18,4);
    
$Cond_code=substr($buffer26,2);    
    
$Calling_num=substr($buffer30,4);
    
$Dialed_num=substr($buffer36,4);
    
//echo "<br>";
    //echo $Dialed_num;
    
$Auth_code=substr($buffer44,4);
    
$in_trk_code=substr($buffer51,2);
    
$in_crt_id=substr($buffer56,2);
    
$Code_used=substr($buffer60,6);
    
$Out_crt_id=substr($buffer69,4);
    
$Out_crt=substr($buffer75,3);
    
    
$Date=trim($Date);//Date
    
$Time=trim($Time);//Time
    
$Sec_dur=trim($Sec_dur);//Sec-dur
    
$Cond_code=trim($Cond_code);//Cond-code
    
$Calling_num=trim($Calling_num);//Calling-num
    
$Dialed_num=trim($Dialed_num);//Dialed-num
    
$Auth_code=trim($Auth_code);//Auth-code
    
$in_trk_code=trim($in_trk_code);//in-trk-code
    
$in_crt_id=trim($in_crt_id);//in-crt_id
    
$Code_used=trim($Code_used);//Code-used
    
$Out_crt_id=trim($Out_crt_id);//Out-crt-id
    
$Out_crt=trim($Out_crt);//Out-crt

    
if($Cond_code!="D" && $Cond_code!=""){

    echo 
"<tr>";
    echo 
"<td>".$cod."</td>";
    echo 
"<td>".$Date."</td>";
    echo 
"<td>".$Time."</td>";
    echo 
"<td>".$Sec_dur."</td>";
    echo 
"<td>".$Cond_code."</td>";
    echo 
"<td>".$Calling_num."</td>";
    echo 
"<td>".$Dialed_num."</td>";
    echo 
"<td>".$Auth_code."</td>";
    echo 
"<td>".$in_trk_code."</td>";
    echo 
"<td>".$in_crt_id."</td>";
    echo 
"<td>".$Code_used."</td>";
    echo 
"<td>".$Out_crt_id."</td>";
    echo 
"<td>".$Out_crt."</td>";
    echo 
"</tr>";

    
$cod++;


    if(
$Auth_code==""){
    
$Auth_code=0;
    }
    if(
$Code_used==""){
    
$Code_used=0;
    }
    if(
$Out_crt_id==""){
    
$Out_crt_id=0;
    }
    if(
$in_crt_id==""){
    
$in_crt_id=0;
    }
    if(
$in_trk_code==""){
    
$in_trk_code=0;
    }

$mysql=mysql_query("INSERT INTO estados (dato1,dato2 ,dato3,dato4,dato5,dato6,dato7,dato8,dato9,dato10,dato11) VALUES ('$Date','$Time','$Sec_dur','$Cond_code','$Calling_num','$Dialed_num', '$Auth_code','$in_trk_code','$in_crt_id','$Code_used','$Out_crt_id')") or die ("problemas en el insert".mysql_error());

    }

    
//}
    
$i++;
    }

    echo 
"</table>";        

    if (!
feof($gestor)) {
        echo 
"Error: fallo inesperado de fgets()\n";

    }
    
fclose($gestor);    
}
mysql_close($link);
?>
mira este es mi código pero no se como hacer el str_replace ni donde ponerlo para que me elimine todas las letras que estén en mi archivo

Me ayudas es que no se como hacer esto :(