hi,

I have a personal thing I'm trying to fix. I just need some help in the right direction to code it myself but I'm unsure of where to start.

I have a canadian version of quicken but I download aussie bank details.

Basically I'm running into trouble because CA Quicken thinks dates are MM/DD/YYYY whereas the Aussie banks give me dates in the txt file which are DD/MM/YY

Here is a sample of a typical txt file I get

!Type:Bank
D02/12/05
T-60.00
PLAW SOCIETY OF NSW SYDNEY
^
D01/12/05
T-32.42
PPRICELINE MID CITY SYDNEY
^
D24/11/05
T-64.40
PCOLES EXPRESS WAHROONGA WAHROONGA
^

I'm sure there must be a simple way to do it in PHP, I want to just make a simple form that will output the changed text on the screen (or ideally give me back another qif file, but I'm not that good yet!)

Here's what I'm thinking initially - explode the variable using "D", then run a loop test to see if the next 8 characters are numbers of "/" symbols - then if it is valid - rearrange the date, obviously it would need to be year proof (so 05 becomes 2005 06 becomes 2006 etc)

any help would be appreciated.

    Try this:

    $file_arr = file('./typical.txt');
    $str = '';
    foreach ($file_arr as $val) {
        if (substr(ltrim($val), 0, 1) == 'D') {
            $arr = explode('/', substr($val, 1));
            $val = 'D' . $arr[1] . '/' . $arr[0] . '/20' . $arr[2];
        }
        $str .= $val;
    }
    
    $fp = fopen('new.qif', 'wb');
    fwrite($fp, $str);
    fclose($fp);
    
    echo '<pre>' . $str . '</pre>';
      Write a Reply...