![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
19/06/2011, 18:37
|
| | Fecha de Ingreso: mayo-2010
Mensajes: 60
Antigüedad: 14 años, 8 meses Puntos: 0 | |
[Ayuda]Lectura de Archivo txt Hola amigos! Se me presenta el siguiente problema al momento de leer este txt....
empleados.txt
Código:
15680708,Patricia,Colmenares,30,Sistemas,5200
18909823,María,Castro,21,Contabilidad,2500
20012345,Carlos,Pérez,18,Sistemas,2100
6234561,Juan,Villamizar,45,Recursos Humanos,5500
4509002,Pedro,Rivero,62,Sistemas,6000
15897034,Diana,Soto,28,Mercadeo,4500
17098456,Ana,Montero,26,Mercadeo,2560
16732210,David,Gutiérrez,27,Recursos Humanos,3700
Necesito leer linea por linea para luego imprimirla tal y como sale en la imagen dependiendo del departamento que yo le envie...
Esta es la clase con mis avances y donde me quede estancado
Código:
<?php
class Empleados {
function listar_departamento($departamento) {
$archivo = 'empleados.txt';
$fp = fopen($archivo,'r');
$arreglo = array();
$i = 0;
while (!feof($fp)) {
/* while($a = fgetcsv($fp, 1000, ",")){
COMO PUEDO HACER PARA PREGUNTAR SI EL CAMPO 4 PERTENECE AL DEPARTAMENTO QUE LLEGÓ COMO PARAMETRO (Se que con if pero nose como hacer la comparativa con el campo 4)
Y AGREGAR LOS DATOS EXTRAIDOS EN UN ARREGLO ASOCIATIVO ?? */
}
fclose($fp);
// Y QUE A CONTINUACION VAYA GUARDANDO EN UNA VARIABLE DE CADENA ($cadena) LO QUE SE IMPRIMIRA EN PANTALLA,
// COMENZANDO POR EL ENCABEZADO
foreach ($arreglo as $emp) {
// AQUI AGREGO LA FILA Y LAS COLUMNAS CON LOS DATOS DEL EMPLEADO
}
$cadena .= '</table>';
return $cadena;
}
}
?>
[URL=http://imageshack.us/photo/my-images/405/sinttuloma.jpg/][IMG]http://img405.imageshack.us/img405/3831/sinttuloma.jpg[/IMG][/URL]
Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL] |