I have a CSV file that I am parsing using PHP. However, the output looks as follows:
Array(
[0] => URL
[1] => Value
[2] => Author
)
Array(
[0] => URL
[1] => Value
[2] => Author
)
Array(
[0] => URL
[1] => Value
[2] => Author
)
And so on...
How can I parse each of these individually and/or display only one at random? I've tried using array_values, but that seems to output all arrays, not just one. Any suggestions? Feel free to let me know if there is anything else I can provide. Thanks guys.
Edit: Added some code if it helps - pretty basic.
//CSV to array and parse
function parseCSV() {
$file = fopen('feeds/data.csv', 'r');
while (($line = fgetcsv($file)) !== FALSE) {
//$line is an array of the csv elements
$arr = $line;
$url = array_values($arr)[2];
$author = array_values($arr)[1];
print_r($arr);
}
fclose($file);
}//end