View Single Post
Old 12-03-2007, 08:20 PM   #11 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Just to offer up another approach (simply to show there are always other options available) here's one using the lovely function: fgetcsv

PHP Code:
<?php

$aUsername 
= array();
$aPassword = array();
$szDbFile  'flatfile.txt';

if (
is_readable($szDbFile))
{
    
$pDb fopen($szDbFile'r');
    while (
false !== ($aDbRow fgetcsv($pDb100'|')))
    {
        if (isset(
$aDbRow[1]))
        {
            
$aUsername[] = $aDbRow[0];
            
$aPassword[] = $aDbRow[1];
        }
    }
    
fclose($pDb);
}


header('Content-Type: text/plain');
var_dump($aUsername$aPassword);
There are drawbacks (and advantages) to using this approach, I'll leave discovering those as an exercise for the reader. :)
Salathe is offline  
Reply With Quote