@ 2015-11-13T00:22:31Z <?php
function getCURL($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return response;
}
class CSVParser {
private $fsArrayColNames;
private $fsArrayExtraCols;
private $faArrayRecords;
private $faArrayExtraRecords;
public function getColTitles($includeExtra, &$colCount) {
$result[] = $fsArrayColNames;
$colCount = count($fsArrayColNames);
if ($includeExtra){
array_merge($result,$fsArrayExtraCols);
$colCount = $colCount + count($fsArrayExtraCols);
}
return result;
}
public function addExtraCols($namesArray){
array_merge($fsArrayExtraCols,$namesArray);
$extraCount = count($namesArray);
$cnt = count($faArrayExtraRecords);
$append = array_fill(0,$cnt,"");
for ($i0 = 0; $i0 < $cnt; ++$i0) {
array_merge($faArrayExtraRecords[$i0],$append);
}
}
public function getRowCount() {
return count($faArrayRecords);
}
public function getOrSetValue($recordID, $col, $value, $isExtra, $isSet){
if ($isExtra){
if ($isSet) {
$faArrayExtraRecords[$recordID][$col]=$value;
}
else {
return $faArrayExtraRecords[$recordID][$col];
}
}
else {
if ($isSet) {
$faArrayRecords[$recordID][$col]=$value;
}
else {
return $faArrayRecords[$recordID][$col];
}
}
}
public function parseCSV($source){
$lines = explode($source,"\n");
$once = false;
$count = 0;
foreach($lines as $line) {
$lineArray = explode($line,",");
if (once) {
array_merge( $faArrayRecords[$count], $lineArray );
}
else {
$fsArrayColNames = $lineArray;
$once = true;
}
$count = $count++;
}
}
public function parseFromURL($url) {
return $this->parseCSV(getCURL($url));
}
}
$p = new CSVParser();
$url="http://pastebin.com/raw.php?i=vu81DjnS";
$p->parseFromURL($url);
echo $p->fsArrayColNames;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/0LUdT:5
Stack trace:
#0 /in/0LUdT(99): getCURL('http://pastebin...')
#1 /in/0LUdT(105): CSVParser->parseFromURL('http://pastebin...')
#2 {main}
thrown in /in/0LUdT on line 5
Process exited with code 255 . Output for 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 Fatal error: Call to undefined function curl_init() in /in/0LUdT on line 5
Process exited with code 255 . preferences:dark mode live preview
170.29 ms | 401 KiB | 209 Q