RayZor
RayZor

Reputation: 665

Explode at delimiter unless delimiter appears in quotes

I have the following string which I need to explode at the ,:

$line = 'C13T110,E010,"WF2010/2510/2540 BK,C,M,Y PACK",0,99.99,EP,EP2,.000,'

The problem I have is that there is are a number of ,'s within the description inside the quotes which are throwing out my resulting array.

How can I explode this string to output the following array:

[0] = C13T110
[1] = E010
[2] = "WF2010/2510/2540 BK,C,M,Y PACK"
[3] = 0
[4] = 99.99
[5] = EP
[6] = EP2
[7] = .000

Upvotes: 1

Views: 163

Answers (1)

Tchoupi
Tchoupi

Reputation: 14691

You are trying to decode CSV format. Use str_getcsv().

See Documentation Here

Upvotes: 6

Related Questions