I'm trying to use preg_split()
but the results aren't what I expect to get from the function.
I'm new to php and the whole preg_split()
scene and it seems to complicated for me to understand, at least for the moment.
$row = "EL10,40,2019-02-06,55555,2019-01-06,ar@email.com,"Text , random text , 52555885/ 48484848484",Yes,One Two,Broke,2019-01-01,000.00,0.00,0.0,0.0,0.0,0.00,0.00,0.0,VRA "Morning";
$row_expl = preg_split('/(?:[^"]*"|)\K\s*(,\s*|$)/',$row);
I expect to remove comma delimiters while leaving commas in quotation marks.
Everything almost seems to work, the only problem occurs at the very end.
It adds extra quotation marks to: VRA "Morning"
.
The result seems like this: "VRA ""Morning"""