Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/02/2016, 08:33
ImHarold
 
Fecha de Ingreso: febrero-2015
Ubicación: Bogotá
Mensajes: 41
Antigüedad: 9 años, 2 meses
Puntos: 1
Respuesta: Contar las lineas de un archivo txt y crear un autoincrement

Gracias por responder, intente de la siguiente manera pero no me cuenta las demás lineas...

Código PHP:
Ver original
  1. $filasP = file('C:\IntranetPV\Pedido.txt');
  2.  
  3.   foreach ($filasP as $valoresP) {
  4.    
  5.       $valoresP1 = trim(str_replace("'", "", $valoresP));
  6.       $linea = explode("'", $valoresP1);
  7.  
  8.       // list($Id, $Id_chk, $FechaP, $Total, $Producto) = explode(",", $valoresP1);
  9.       // $InsertP = mysql_query("REPLACE INTO pedido(Id_chk, FechaP, Total, Producto) VALUES ('$Id_chk','$FechaP','$Total','$Producto')", $conexion);
  10.  
  11.       $final = array();
  12.  
  13.       foreach ($linea as $key => $value) {
  14.       $final [] = ($key + 1).",$value";
  15.       // echo join("", $final);
  16.       echo "<br>";
  17.       var_dump($final);
  18.       }
  19.  
  20.   }

Me arroja los datos de la siguiente manera:

array(1) { [0]=> string(54) "1,2759,2016-02-24 08:15:17.000,60998,Serv. Domicilio,1" }
array(1) { [0]=> string(55) "1,2759,2016-02-24 08:15:17.000,60998,Huev. SoloClaras,1" }
array(1) { [0]=> string(55) "1,2759,2016-02-24 08:15:17.000,60998,Empq Fritat Desy,1" }
array(1) { [0]=> string(55) "1,2761,2016-02-24 08:23:02.000,169993,Serv. Domicilio,1" }
array(1) { [0]=> string(53) "1,2761,2016-02-24 08:23:02.000,169993,Prom Lasagnas,1" }
array(1) { [0]=> string(51) "1,2761,2016-02-24 08:23:02.000,169993,Lasag Mixta,1" }
array(1) { [0]=> string(53) "1,2761,2016-02-24 08:23:02.000,169993,Empq Lasagnas,1" }

Arroja los datos pero no me hace el conteo :(
__________________
La vida es un juego de Ajedrez.