This is my code for reading a CSV file using an array. But it shows an error called Undefined offset:1 Please can anyone say what is wrong with my code? Also I want to print the result in an HTML table. How can I do that?
class ProjectController extends Controller
{
 public function index($id)
{
    $project = Project::find($id);
    $data = array();
    // read the CSV and assign the data to $data
    $filename = public_path("/uploads/{$id}.csv");
    $file = fopen($filename, "r");
    $all_data = array();
    while (($data = fgetcsv($file, 200, ",")) !== FALSE) {
        $Keywords = $data[0];
        $Avg_search_volumn = $data[1];
        $Top_of_the_page_bid_low = $data[2];
        $all_data = $Keywords . " " . $Avg_search_volumn . " " . $Top_of_the_page_bid_low;
        array_push($array, $all_data);
    }
    fclose($file);
    echo "<pre>";
    print_r($all_data);
    die;
    return view('home')->with('project', $project)->with('data', $data);
   }
  }
