Re: preg_split - spliting string
| From: | Bambero | Date: | Sun, 07 Mar 2004 13:06:09 +0000 |
| Subject: | Re: preg_split - spliting string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-179692@lists.php.net to get a copy of this message | ||
Burhan Khalid wrote:
Bambero wrote:Hmmm is it the best solution ? Is there any way to do that with preg_split ?Hi I need to split a string by the: , (comma) separator, but when the comma is beetwen "" it should be skipped. Ex: test ts sasa, assas "sasa,asaas" dasdas, da => test ts sasa => assas "sasa,asaas" dasdas => daIf this is a CSV file, you can try fgetcsv. From http://www.php.net/fgetcsv "Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read. The optional third delimiter parameter defaults as a comma, and the optional enclosure defaults as a double quotation mark. Both delimiter and enclosure are limited to one character. If either is more than one character, only the first character is used. Note: The enclosure parameter was added in PHP 4.3.0."