fopen関数を利用してCSVファイルを読み取っています。 18〜33行目. fgetcsv関数によって一行ごとに処理を行っていきます。 35行目. ファイルポインタを閉じます。 sample.csvを読み込んで表示させた結果 PHP. $users = User::all()->toArray();$stream = fopen('php://output', 'w');foreach ($users as $user) { fputcsv($stream, $user);}$headers = array( 'Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="users.csv"',);return Response::make('', 200, $headers); 1. 2. 3. 4.
Install - https://github.com/Maatwebsite/Laravel-Excel. And then Try below code: $reader = \Excel::load($file_path); //this will load file $results = $reader->noHeading()->get()->toArray(); //this will convert file to array foreach($results as $v){ \\process your array }