note 32081 added to function.explode

From: Date: Thu, 15 May 2003 20:37:42 +0000
Subject: note 32081 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-48044@lists.php.net to get a copy of this message
I had problems with the above function returning empties when there shouldn't be. Here's my take. I hope some of you find this of value. function csv_explode2($str, $delim=',', $qual="\"") { $len=strlen($str); $inside=0; for ($i =0; $i<$len; $i++) { if ($str[$i]==$delim && !$inside) { $out[]=$word; $word=''; }else if ($str[$i]==$qual) { $inside=!$inside; } else { $word.=$str[$i]; } } return $out; } -- http://www.php.net/manual/en/function.explode.php http://master.php.net/manage/user-notes.php?action=edit+32081 http://master.php.net/manage/user-notes.php?action=delete+32081 http://master.php.net/manage/user-notes.php?action=reject+32081

« previous php.notes (#48044) next »