note 98401 added to function.str-getcsv

From: Date: Sat, 12 Jun 2010 23:50:57 +0000
Subject: note 98401 added to function.str-getcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-170091@lists.php.net to get a copy of this message
This function sometimes incorrect work with csv-files produced by Excel 2007. I'm wrote shortly and correct analog: function csv2array($s) { preg_match_all('/(("([^"]|"")*")|(((?<=;)|(?<=^))[^";]*))(;|$)/u', $s, $m); // check format $n = 0; foreach($m[0] as $l) $n += mb_strlen($l); // incorrect format if ($n != mb_strlen($s)) return false; foreach($m[1] as &$l) if (mb_substr($l, 0, 1)=='"') $l = str_replace('""', '"', mb_substr($l, 1, -1)); return $m[1]; } ---- Server IP: 69.147.83.197 Probable Submitter: 91.200.224.20 ---- Manual Page -- http://www.php.net/manual/en/function.str-getcsv.php Edit -- https://master.php.net/note/edit/98401 Del: integrated -- https://master.php.net/note/delete/98401/integrated Del: useless -- https://master.php.net/note/delete/98401/useless Del: bad code -- https://master.php.net/note/delete/98401/bad+code Del: spam -- https://master.php.net/note/delete/98401/spam Del: non-english -- https://master.php.net/note/delete/98401/non-english Del: in docs -- https://master.php.net/note/delete/98401/in+docs Del: other reasons-- https://master.php.net/note/delete/98401 Reject -- https://master.php.net/note/reject/98401 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170091) next »