<?php
    
function parse_csv($csv) {
        
preg_match_all('/(?<=^|,)("(.|\n)*(?<!")"|.*)(,|$)/Um'$csv$matchesPREG_SET_ORDER);
        
$rows = array();
        
$fields = array();
        foreach (
$matches as $match) {
            
$field $match[1];
            if (
$field != '' && $field != '"' && $field[0] == '"' && substr($field, -1) == '"') {
                
$field substr($field1, -1);
                
$field str_replace('""''"'$field);
            }
            
$fields[] = $field;
            if (
$match[3] == '') {
                
$rows[] = $fields;
                
$fields = array();
            }
        }
        return 
$rows;
    }
?>