Jump to content


Photo

Manipulate a CSV file


  • Please log in to reply
1 reply to this topic

#1 solarisuser

solarisuser
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 01 August 2006 - 05:35 AM

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!

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 01 August 2006 - 07:42 AM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users