<?php
$str = '"1234 567" 123 3456 "3123 23" 432 32 423 "432 43" 432';
$arr = preg_split("/^\"|(\" )|( \")| (?=[ \d]+$)|( (?=[ \d]*( \")))/", $str);
print_r($arr);
?>

解决方案 »

  1.   

    绞尽脑汁去思索这类问题似乎没有多大意义
    你可以用stream函数库轻松的解决此类问题,手册中就有现成的例子stream_wrapper_register("csvstr", "csvstream") ; 
    $str = '"1234 567" 123 3456 "3123 23"';
    $fp = fopen("csvstr://str", "r+");  
    print_r(fgetcsv($fp,100," ",'"')); csvstream类定义
    class csvstream { 
       var $position;  
       var $varname;  
       function stream_open($path, $mode, $options, &$opened_path){  
           $url = parse_url($path);  
           $this->varname = $url['host'] ; 
           $this->position = 0;  
           return true; 
       } 
      function stream_read($count){  
           $ret = substr($GLOBALS[$this->varname], $this->position, $count);  
           $this->position += strlen($ret);  
           return $ret;  
       } 
      function stream_eof(){  
           return $this->position >= strlen($GLOBALS[$this->varname]);  
       }  
       function stream_tell(){  
           return $this->position;  
       }