Answer the question
In order to leave comments, you need to log in
What is the correct way to parse a csv file?
How to parse csv file? The file is on another site, this is such a centralization with settings, I
try to parse like this
$myurl = $sym_link . "data/soc_links.csv";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $myurl);
curl_setopt($curl, CURLOPT_REFERER, $sym_link);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
// разбиваем по строкам
$res = explode("\r\n",$response);
foreach($res as $line)
{
$elem = explode("<|>",$line);
//var_dump($elem);
echo ("<li><a href=".$elem[1]." target='_blank'>".$elem[2]."</a></li>");
}
1<|>#<|>RSS
2<|>#<|>Facebook
3<|>#<|>Twitter
4<|>#<|>Google+
5<|>#<|>Flickr
$cat = file("data/soc_links.csv");
foreach($cat as $line)
{
$elem = explode("<|>",$line);
echo ("<li><a href=".$elem[1]." target='_blank'>".$elem[2]."</a></li>");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question