This is a tricky one, I have a .txt file which has about 2,000 registers with employees names, ids, address, date of birth and etc.
I need to read this file and get only the employees ID numbers and their names.
I found out how to find a specific value on the .txt file, for example “ID” but I need to get what comes after it, which is the actual ID number, and do the same for the name,, so at the end I have an array with all the employess names and ID numbers.
This is how I´m doing:
[code=php]<?
$key = “ID”;
$key2 = “name”;
//load file into $fc array
$fc = file(“Employees.txt”);
foreach($fc as $line_num => $line){
echo “Line:<b>{$line_num}</b> : ” . $line . “<br />n”;
if (strstr($line,$key)){
echo “———————Found the ID:” .$key. “————————-<br>”;
}
}
fclose($fc);
?>
The way it is, I only find out whenever there is a “ID” string on the .txt when I need what comes after it, so I can put it into an array. Anyone ever had to do something like this?? Tks