Yaaqov
Yaaqov

Reputation: 305

In PHP, Removing first element in CSV String

I'm simply looking to take the first csv out of a string, using PHP. Here are a few examples:

And so on...

Thank you.

Upvotes: 0

Views: 419

Answers (2)

Not Available
Not Available

Reputation: 3355

I suggest using str_getcsv or something similar that parses csv, this will take into account any quotation marks and commas in the CSV string. after that you can just array_shift

Upvotes: 1

xil3
xil3

Reputation: 16439

You can try this:

$csvArray = explode(",", $csv);
array_shift($csvArray);
$newCsv = implode(",", $csvArray);

Upvotes: 2

Related Questions