如何在PHP中从csv文件将特定列放入变量中

如何在PHP中从csv文件将特定列放入变量中,php,csv,variables,Php,Csv,Variables,谢谢,请提供帮助您能举一个数据示例,或者进一步说明您的问题吗? //here is my code which is giving and array of the file $csv = array_map("str_getcsv", file("Copy of data.csv",FILE_SKIP_EMPTY_LINES)); $keys = array_shift($csv); //To turn all the rows into a ni

谢谢,请提供帮助

您能举一个数据示例,或者进一步说明您的问题吗?
//here is my code which is giving and array of the file

$csv = array_map("str_getcsv", file("Copy of data.csv",FILE_SKIP_EMPTY_LINES));

$keys = array_shift($csv);

//To turn all the rows into a nice associative array you could then apply:

foreach ($csv as $i=>$row) {

    $csv[$i] = array_combine($keys, $row);

    echo '<pre>';

    print_r( $csv[$i] );

    echo '</pre>';
    
}
$f_name  = 'fisrt name'; // from csv file