我正在尝试分配带有CSV文件的二维数组。 当我尝试打印二维数组中的第一个值以进行检查时,它不会打印任何内容

I would like to know if the 2-D array is getting assigned properly, if yes, then why can't I echo it, and if no, then where am I going wrong?

    $ratings=array(array());
    ini_set('auto_detect_line_endings',TRUE);
    $file_handle=fopen("C:/Users/Kartik Krishna Kumar/Desktop/Internship/Opinion comparison algo/userratings.csv","r");
    $i=0;
    while(($data=fgetcsv($file_handle,10000,","))!=FALSE){
        $n=count($data);
        for($j=0;$j<$n;$j++)
        {
            $ratings[$i][$j]=$data[$j];
        }               
        $i++;
    }
    echo $ratings[0][0];
    fclose($file_handle);

A person asked for the CSV file sample, I'm afraid I'm not able to provide it. But, I can tell you that it is a matrix (1000*10000) of numbers (range 1-10). And the problem isn't an error, the problem is, nothing is getting printed and I have no idea why. I have checked for the existence of the file and am pretty sure the values are being passed.

Update: Okay, now the ratings are getting stored inside the array, but not exactly how I wanted it to be. For some reason, only the first row is properly stored and after that any row I try to use has different values (mostly 0) compared to that of in the excel sheet. Any help would be appreciated!

You are echoing only 0th element.

Replace echo $ratings[0][0]; to print_r($ratings); to display full array.

I have added a load of debugging which should unpick it for you

$ratings=array();//you dont need to initialise as 2d
ini_set('auto_detect_line_endings',TRUE);
$file_handle=fopen("C:/Users/Kartik Krishna Kumar/Desktop/Internship/Opinion comparison algo/userratings.csv","r");

//see if your handle is valid - should look like 'resource #12' if its good
var_dump($file_handle);

while(($data=fgetcsv($file_handle,10000,","))!=FALSE){
    //see if something is in the $data array first        
    var_dump($data);
    //a simpler version of your loop
    foreach($data as $key=>$row){
          //check your accesssing your $row ok
          var_dump($row);
          //add your $row item to your $ratings
          $ratings[$key]=$row; //you probably dont need to nest to 2 levels here or define a key if you are just using an arbitrary count
    }
}
var_dump($ratings);//see the whole thing

//you probably have an array in here so echo is no good
//echo $ratings[0][0]; 

//see the contents of the first index
var_dump($ratings[0]); //we removed a level

fclose($file_handle);