You are here: Re: Comma delimited file « PHP Programming Language « IT news, forums, messages
Re: Comma delimited file

Posted by Roman Ziak on 07/29/06 22:43

Chuck Anderson wrote:
> Bertie Brink wrote:
>> I am trying to read comma delimited rows of text. The problem is that
>> some fields may be encapsulated in "" - particularly the text fields
>> but not numeric fields.
>>
>> Is there a simple efficient way to parse the fields with comma but
>> also strip off the "" encapsulating some of the fields with php?
>>
>> The problem is the "" encapsulation is optional. Some fields will have
>> it, some won't.
>>
>> Thanks
>>
> Once you have parsed out a field, use:
>
> trim($field, '"'); (that's single quote - double quote - single quote)
>
> ... which will remove " from the beginning and end of $field, if present.
>

Quotas are used for fields which (may) contain comma, so parser needs to
mind quotas and when found opening quota, should stop only on end of
line or the closing quota.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация