Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complicated string output problem

Status
Not open for further replies.
May 22, 2002
63
GB
Hi,

I', trying to write a piece of code that reads a string and only outputs the information that sits before a space:

i.e.

"anders@dwl.co.uk Subject:"

would be outputted as

"anders@dwl.co.uk"

I need to do this as I am trying to strip email addresses from a large CSV file and have nearly cracked it but I just can't get it to display everything before a space is encountered?

Any ideas?

My code at the moment is like this:

$fp = fopen ("rejects.csv","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
$emailarray = split("o:", $data[0]);
$output1 = substr($emailarray[1],0,60);
$output1 = trim($output1);
$output1 = strtok($output1," ");
$output1 = strtok($output1," ");

print $output1;

print &quot;<hr>&quot;;
}

Thanks,

Anders
 
Its ok i solved it, the space was displaying as a space in the browser but was actually a carriage return in the CSV, so I split at &quot;\n&quot; and it works great now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top