Jump to content

Archived

This topic is now archived and is closed to further replies.

solarisuser

Manipulate a CSV file

Recommended Posts

Hello All!

I have a comma delimited file and I want to remove the start of the line until it hits the first comma.

For example:

23-28331,Blah,Blah Blah, Blah
27-442-9,Blah2, Blahhhh, Blah Blah Blah


I would like to end up with:

Blah, Blah Blah, Blah
Blah2, Blahhhh, Blah Blah Blah

Should I look into preg_replace, split, or something else?

Any ideas or code would be greatly appriciated!

Share this post


Link to post
Share on other sites
[code]
<?php
$string = <<<LLL
23-28331,Blah,Blah Blah, Blah
27-442-9,Blah2, Blahhhh, Blah Blah Blah
LLL;
$string = preg_replace('/^[^,]*,/m', '', $string);
echo $string
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.