Answer the question
In order to leave comments, you need to log in
How to get specific values from an array?
Hello! This is how I output the csv file to an array.
<?php
$csvArray = array();
$csvData = file_get_contents('file.csv');
$lines = explode(PHP_EOL, $csvData);
foreach ($lines as $line) {
$csvArray[] = str_getcsv($line);
}
echo '<pre>';
print_r($csvArray);
echo '</pre>';
?>
Answer the question
In order to leave comments, you need to log in
In your example, the str_getcsv() function is completely useless. Your separator is a semicolon, and the str_getscv() function works with a comma separator by default. Change
to
After the action, the elements will be divided as needed, and as a result, you can get the first element in this way: $csvArray[0][0] $csvArray[0][1] and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question