$filesName = File::files(base_path().'databasemigrations'); $arr = []; foreach ($filesName as $file) { $ex = explode("" , $file); array_push($arr , $ex[count($ex) - 1]); }