|
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]
|