Re: [PHP] preg_split - spliting string

2004-03-07 Thread Bambero


Burhan Khalid wrote:
Bambero wrote:

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
= da
If 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.





Hmmm is it the best solution ? Is there any way to do that with preg_split ?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] preg_split - spliting string

2004-03-06 Thread Burhan Khalid
Bambero wrote:
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
= da
If 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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php