W4H1d-2016 / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Phone formatting not working #113

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Phone formatted fields in Excel 2003 don't show up properly. They output 
something like this: [<=1234567891]1234567891-123456789

I made a fix by passing: format_phone($class_ref->val($row,$col,$sheet))

To this function...

function format_phone($phone) {
    $new_phone = preg_replace("/\[<=(\d{10,})\](\d{10,})-(\d{3,})(\d{3})(\d{4})/", "($3) $4-$5", $phone); //Outputs (###) ###-####

    if($new_phone == $phone || $new_phone == null) {
        return $phone;
    }else{
        return $new_phone;
    }
}

Original issue reported on code.google.com by rob...@teatimevo.com on 12 Apr 2011 at 11:42