note 63259 added to function.fgetcsv
| From: | simone dot sanfratelloattiscalidotit at osu1 dot php dot net | Date: | Fri, 17 Mar 2006 14:30:41 +0000 |
| Subject: | note 63259 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105982@lists.php.net to get a copy of this message | ||
to get an array with data from the MS Excel csv format (separated by ; and with string wich contains
; or " optionally delimited by " )
function getcsvxls($buffer)
{
$buffer = str_replace('""', '"', $buffer);
$n = strlen($buffer);
$i = $line = 0;
$del = false;
while($i < $n)
{
$part = substr($buffer, $i);
if(
(substr($part, 0, 1) == ';' && !$del) ||
(substr($part, 0, 2) == '";' && $del)
)
{
$i ++;
if($del)
{
$str = substr($str, 1, strlen($str) - 1);
$i ++;
}
$data[$line][] = $str;
$del = false;
$str = '';
} else if(substr($part, 0, 2) == "\r\n")
{
$data[$line][] = $str;
$str = '';
$del = false;
$line ++;
$i += 2;
} else
{
if($part[0] == '"')
$del = true;
$str .= $part[0];
$i ++;
}
}
return $data;
}
----
Server IP: 80.241.173.254
Probable Submitter: 81.208.92.210
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- http://master.php.net/note/edit/63259
Del: integrated -- http://master.php.net/note/delete/63259/integrated
Del: useless -- http://master.php.net/note/delete/63259/useless
Del: bad code -- http://master.php.net/note/delete/63259/bad+code
Del: spam -- http://master.php.net/note/delete/63259/spam
Del: non-english -- http://master.php.net/note/delete/63259/non-english
Del: in docs -- http://master.php.net/note/delete/63259/in+docs
Del: other reasons-- http://master.php.net/note/delete/63259
Reject -- http://master.php.net/note/reject/63259
Search -- http://master.php.net/manage/user-notes.php