Possible Duplicate:
how to extract data from csv file in php
i’m new on php and now i try to make a private site for me and read out some stock information over yahoo api
Link: finance.yahoo.com/d/quotes.csv?s=^GDAXI+^TECDAX+eurusd=x+gcf12.cmx+CLH12.NYM&f=nl1k2
The link works fine but now how can i read this file out? And echo the information on my page?
Output:
"DAX",6864.43,"+54.97 - +0.81%"
"TECDAX",775.33,"+3.78 - +0.49%"
"EUR to USD",1.3447,"N/A - 0.00%"
"Gold Jan 12",1731.80,"N/A - +0.32%"
"Crude Oil Mar 12",105.88,"N/A - +0.04%"
What i need:
echo $name;
echo $rate;
echo $change;
echo $changeinpercent;
I hope some one can help me, and sry for my bad english.
Greetings,
matthias
You could use RegEx to extract from each line the information you need. The following php code is what you need to extract this specific data. It’s a RegEx code and you should use it with a preg_match function:
It gives you an array, and you will use it as:
UPDATE:
This is the code to do it:
It returns:
If it is N/A you will find it in $matches[3], if a value in 4.
)